Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add check for account existence before login and display error message if not found #133

Merged
merged 3 commits into from
Oct 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 justify-between items-center 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>
Loading