Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
RhysLees committed Oct 20, 2023
1 parent 8cb4b79 commit 71c36a8
Show file tree
Hide file tree
Showing 5 changed files with 64 additions and 55 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -296,9 +296,7 @@ return [
|
*/
'providers' => [
'disabled' => [
// ProviderEnum::MICROSOFT_OFFICE_365(),
],
ProviderEnum::MICROSOFT_OFFICE_365(),
],


Expand All @@ -311,6 +309,8 @@ return [
|
*/
'features' => [
'basic' => true,
'sso' => true,
'password_reset' => true,
'email_verification' => true,
],
Expand Down
11 changes: 6 additions & 5 deletions config/laravel-auth.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,16 +85,15 @@
|--------------------------------------------------------------------------
| Provider Settings
|--------------------------------------------------------------------------
| By default, all providers are enabled.
| You may disable a provider by adding it to the disabled array.
| Add the providers you want to use here.
| e.g ProviderEnum::MICROSOFT_OFFICE_365(),
|
*/
'providers' => [
'disabled' => [
ProviderEnum::MICROSOFT_OFFICE_365(),
],
ProviderEnum::MICROSOFT_OFFICE_365(),
],


/*
|--------------------------------------------------------------------------
| Feature Settings
Expand All @@ -104,6 +103,8 @@
|
*/
'features' => [
'basic' => true,
'sso' => true,
'password_reset' => true,
'email_verification' => true,
],
Expand Down
92 changes: 49 additions & 43 deletions resources/views/login.blade.php
Original file line number Diff line number Diff line change
@@ -1,59 +1,65 @@
<x-auth::layout>
<h2 class="mt-6 text-center text-2xl font-bold leading-9 tracking-tight text-gray-900">{{ __('auth::translations.login') }}</h2>

<form class="mt-8 space-y-4" action="{{ route('auth.login.store') }}" method="POST">
@csrf
@honeypot
@if(config('laravel-auth.features.basic'))
<form class="mt-8 space-y-4" action="{{ route('auth.login.store') }}" method="POST">
@csrf
@honeypot

<x-auth::form.input
type="email"
name="email"
:label="__('auth::translations.email')"
:placeholder="__('auth::translations.email')"
autocomplete="email"
:required="true"
:required-badge="false"
:autofocus="true"
/>

<x-auth::form.password
name="password"
:label="__('auth::translations.password')"
:placeholder="__('auth::translations.password')"
autocomplete="password"
:required="true"
:required-badge="false"
/>
<x-auth::form.input
type="email"
name="email"
:label="__('auth::translations.email')"
:placeholder="__('auth::translations.email')"
autocomplete="email"
:required="true"
:required-badge="false"
:autofocus="true"
/>

<div class="flex items-center justify-between">
<x-auth::form.checkbox
name="remember"
:label="__('auth::translations.remember-me')"
<x-auth::form.password
name="password"
:label="__('auth::translations.password')"
:placeholder="__('auth::translations.password')"
autocomplete="password"
:required="true"
:required-badge="false"
/>

@if(config('laravel-auth.features.password_reset'))
<div class="flex items-center">
<a href="{{ route('auth.request-password') }}"
class="block text-sm text-gray-900 hover:text-gray-500 underline">{{ __('auth::translations.forgot-password') }}</a>
</div>
@endif
</div>
<div class="flex items-center justify-between">
<x-auth::form.checkbox
name="remember"
:label="__('auth::translations.remember-me')"
/>

<div class="space-y-4">
<x-auth::form.button.button>
{{ __('auth::translations.sign-in') }}
</x-auth::form.button.button>
@if(config('laravel-auth.features.password_reset'))
<div class="flex items-center">
<a href="{{ route('auth.request-password') }}" class="block text-sm text-gray-900 hover:text-gray-500 underline">
{{ __('auth::translations.forgot-password') }}
</a>
</div>
@endif
</div>

@if(! in_array(\CodebarAg\LaravelAuth\Enums\ProviderEnum::MICROSOFT_OFFICE_365(), config('laravel-auth.providers.disabled')))
<div class="space-y-4">
<x-auth::form.button.button>
{{ __('auth::translations.sign-in') }}
</x-auth::form.button.button>
</div>
</form>
@endif

<div class="space-y-4">
@if(config('laravel-auth.features.sso'))
@if(in_array(\CodebarAg\LaravelAuth\Enums\ProviderEnum::MICROSOFT_OFFICE_365(), config('laravel-auth.providers')))
<x-auth::form.button.ahref
:href="route('auth.provider', \CodebarAg\LaravelAuth\Enums\ProviderEnum::MICROSOFT_OFFICE_365())"
class="bg-gray-500 hover:bg-gray-400"
:href="route('auth.provider', \CodebarAg\LaravelAuth\Enums\ProviderEnum::MICROSOFT_OFFICE_365())"
class="bg-gray-500 hover:bg-gray-400"
>
<svg class="fill-white w-4 h-4" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 278050 333334" shape-rendering="geometricPrecision" text-rendering="geometricPrecision" image-rendering="optimizeQuality" fill-rule="evenodd" clip-rule="evenodd"><path fill="currentColor" d="M278050 305556l-29-16V28627L178807 0 448 66971l-448 87 22 200227 60865-23821V80555l117920-28193-17 239519L122 267285l178668 65976v73l99231-27462v-316z"/></svg>
<span>{{ __('auth::translations.sign-in-with-microsoft') }}</span>
</x-auth::form.button.ahref>
@endif
</div>

</form>
@endif
</div>
</x-auth::layout>
8 changes: 5 additions & 3 deletions routes/auth.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,11 @@
Route::get('/')->uses([LoginController::class, 'index'])
->name('login');

Route::post('/store')->uses([LoginController::class, 'store'])
->middleware(ProtectAgainstSpam::class)
->name('login.store');
if (config('laravel-auth.features.basic')) {
Route::post('/store')->uses([LoginController::class, 'store'])
->middleware(ProtectAgainstSpam::class)
->name('login.store');
}
});

if (config('laravel-auth.features.password_reset')) {
Expand Down
2 changes: 1 addition & 1 deletion src/Controllers/ProviderController.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public function serviceRedirect($service)

protected function allowed($provider)
{
if (in_array($provider->value, config('laravel-auth.providers.disabled'))) {
if (!in_array($provider->value, config('laravel-auth.providers'))) {
abort(503);
}
}
Expand Down

0 comments on commit 71c36a8

Please sign in to comment.