Skip to content

Commit

Permalink
Merge pull request #137 from thedevdojo/artisancorpsmain
Browse files Browse the repository at this point in the history
feat: Add check for account existence before login and display error message if not found
  • Loading branch information
tnylea authored Oct 25, 2024
2 parents dede5df + c3eaf41 commit aec1bf1
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 4 deletions.
1 change: 1 addition & 0 deletions config/devdojo/auth/descriptions.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,6 @@
'login_show_social_providers' => 'Show the social providers login buttons on the login form',
'center_align_social_provider_button_content' => 'Center align the content in the social provider button?',
'social_providers_location' => 'The location of the social provider buttons (top or bottom)',
'check_account_exists_before_login' => 'Determines if the system checks for account existence before login',
],
];
1 change: 1 addition & 0 deletions config/devdojo/auth/language.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
'sign_up' => 'Sign up',
'social_auth_authenticated_message' => 'You have been authenticated via __social_providers_list__. Please login to that network below.',
'change_email' => 'Change Email',
'couldnt_find_your_account' => 'Couldn’t find your account',
],
'register' => [
'page_title' => 'Sign up',
Expand Down
1 change: 1 addition & 0 deletions config/devdojo/auth/settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,5 @@
'login_show_social_providers' => true,
'center_align_social_provider_button_content' => false,
'social_providers_location' => 'bottom',
'check_account_exists_before_login' => false,
];
16 changes: 12 additions & 4 deletions resources/views/pages/auth/login.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,14 @@ public function authenticate()
return;
}
}
// Check if account exists before login and handle error if user is not found
if(config('devdojo.auth.settings.check_account_exists_before_login') && is_null($userTryingToValidate)){
$this->js("setTimeout(function(){ window.dispatchEvent(new CustomEvent('focus-email', {})); }, 10);");
$this->addError('email', trans(config('devdojo.auth.language.login.couldnt_find_your_account')));
return;
}
$this->showPasswordField = true;
$this->js("setTimeout(function(){ window.dispatchEvent(new CustomEvent('focus-password', {})); }, 10);");
return;
Expand Down Expand Up @@ -125,7 +133,7 @@ public function authenticate()
?>

<x-auth::layouts.app title="{{ config('devdojo.auth.language.login.page_title') }}">

@volt('auth.login')
<x-auth::elements.container>

Expand Down Expand Up @@ -168,7 +176,7 @@ public function authenticate()

@if($showPasswordField)
<x-auth::elements.input :label="config('devdojo.auth.language.login.password')" type="password" wire:model="password" id="password" data-auth="password-input" />
<x-auth::elements.checkbox :label="config('devdojo.auth.language.login.remember_me')" wire:model="rememberMe" id="remember-me" data-auth="remember-me-input" />
<x-auth::elements.checkbox :label="config('devdojo.auth.language.login.remember_me')" wire:model="rememberMe" id="remember-me" data-auth="remember-me-input" />
<div class="flex items-center justify-between mt-6 text-sm leading-5">
<x-auth::elements.text-link href="{{ route('auth.password.request') }}" data-auth="forgot-password-link">{{ config('devdojo.auth.language.login.forget_password') }}</x-auth::elements.text-link>
</div>
Expand All @@ -191,5 +199,5 @@ public function authenticate()

</x-auth::elements.container>
@endvolt
</x-auth::layouts.app>

</x-auth::layouts.app>

0 comments on commit aec1bf1

Please sign in to comment.