From 50562316cce97f954af01c6adf2b4f1d5addac7c Mon Sep 17 00:00:00 2001 From: Aboo Thahir Date: Fri, 27 Sep 2024 10:40:43 +0530 Subject: [PATCH] feat: Add check for account existence before login and display error message if not found --- config/devdojo/auth/descriptions.php | 1 + config/devdojo/auth/language.php | 1 + config/devdojo/auth/settings.php | 1 + resources/views/pages/auth/login.blade.php | 16 ++++++++++++---- 4 files changed, 15 insertions(+), 4 deletions(-) diff --git a/config/devdojo/auth/descriptions.php b/config/devdojo/auth/descriptions.php index 283fb5e..3f1a8fb 100644 --- a/config/devdojo/auth/descriptions.php +++ b/config/devdojo/auth/descriptions.php @@ -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', ], ]; diff --git a/config/devdojo/auth/language.php b/config/devdojo/auth/language.php index afe5aa0..d49616b 100644 --- a/config/devdojo/auth/language.php +++ b/config/devdojo/auth/language.php @@ -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', diff --git a/config/devdojo/auth/settings.php b/config/devdojo/auth/settings.php index 1455ba6..a088429 100644 --- a/config/devdojo/auth/settings.php +++ b/config/devdojo/auth/settings.php @@ -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, ]; diff --git a/resources/views/pages/auth/login.blade.php b/resources/views/pages/auth/login.blade.php index 996d308..9ea70f2 100644 --- a/resources/views/pages/auth/login.blade.php +++ b/resources/views/pages/auth/login.blade.php @@ -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; @@ -125,7 +133,7 @@ public function authenticate() ?> - + @volt('auth.login') @@ -168,7 +176,7 @@ public function authenticate() @if($showPasswordField) - +
{{ config('devdojo.auth.language.login.forget_password') }}
@@ -191,5 +199,5 @@ public function authenticate()
@endvolt - -
\ No newline at end of file + +