From 3f83b7f0ab6ae24952bd3182074d5bc45ad8dc46 Mon Sep 17 00:00:00 2001 From: skdishansachin Date: Wed, 3 Jul 2024 13:32:33 +0530 Subject: [PATCH 1/2] update the styles --- resources/views/pages/auth/login.blade.php | 160 ++++++++++----------- 1 file changed, 76 insertions(+), 84 deletions(-) diff --git a/resources/views/pages/auth/login.blade.php b/resources/views/pages/auth/login.blade.php index b90f2d5..1b29466 100644 --- a/resources/views/pages/auth/login.blade.php +++ b/resources/views/pages/auth/login.blade.php @@ -6,7 +6,7 @@ use Livewire\Volt\Component; use Devdojo\Auth\Traits\HasConfigs; -if(!isset($_GET['preview']) || (isset($_GET['preview']) && $_GET['preview'] != true) || !app()->isLocal()){ +if (!isset($_GET['preview']) || (isset($_GET['preview']) && $_GET['preview'] != true) || !app()->isLocal()) { middleware(['guest']); } @@ -35,18 +35,20 @@ public $userModel = null; - public function mount(){ + public function mount() + { $this->loadConfigs(); $this->twoFactorEnabled = $this->settings->enable_2fa; $this->userModel = app(config('auth.providers.users.model')); } - public function editIdentity(){ - if($this->showPasswordField){ + public function editIdentity() + { + if ($this->showPasswordField) { $this->showPasswordField = false; return; } - + $this->showIdentifierInput = true; $this->showSocialProviderInfo = false; } @@ -54,14 +56,14 @@ public function editIdentity(){ public function authenticate() { - if(!$this->showPasswordField){ + if (!$this->showPasswordField) { $this->validateOnly('email'); $userTryingToValidate = $this->userModel->where('email', $this->email)->first(); - if(!is_null($userTryingToValidate)){ - if(is_null($userTryingToValidate->password)){ + if (!is_null($userTryingToValidate)) { + if (is_null($userTryingToValidate->password)) { $this->userSocialProviders = []; // User is attempting to login and password is null. Need to show Social Provider info - foreach($userTryingToValidate->socialProviders->all() as $provider){ + foreach ($userTryingToValidate->socialProviders->all() as $provider) { array_push($this->userSocialProviders, $provider->provider_slug); } $this->showIdentifierInput = false; @@ -79,113 +81,103 @@ public function authenticate() $credentials = ['email' => $this->email, 'password' => $this->password]; - if(!\Auth::validate($credentials)){ + if (!\Auth::validate($credentials)) { $this->addError('password', trans('auth.failed')); return; } $userAttemptingLogin = $this->userModel->where('email', $this->email)->first(); - if(!isset($userAttemptingLogin->id)){ + if (!isset($userAttemptingLogin->id)) { $this->addError('password', trans('auth.failed')); return; } - if($this->twoFactorEnabled && !is_null($userAttemptingLogin->two_factor_confirmed_at)){ + if ($this->twoFactorEnabled && !is_null($userAttemptingLogin->two_factor_confirmed_at)) { // We want this user to login via 2fa session()->put([ 'login.id' => $userAttemptingLogin->getKey() ]); return redirect()->route('auth.two-factor-challenge'); - } else { if (!Auth::attempt($credentials)) { $this->addError('password', trans('auth.failed')); return; } - + event(new Login(auth()->guard('web'), $this->userModel->where('email', $this->email)->first(), true)); - if(session()->get('url.intended') != route('logout.get')){ + if (session()->get('url.intended') != route('logout.get')) { redirect()->intended(config('devdojo.auth.settings.redirect_after_auth')); } else { return redirect(config('devdojo.auth.settings.redirect_after_auth')); } } - } }; ?> -
- @volt('auth.login') -
- - - - - - - @if(config('devdojo.auth.settings.login_show_social_providers') && config('devdojo.auth.settings.social_providers_location') == 'top') - - @endif - -
- - @if($showPasswordField) - - - - @else - @if($showIdentifierInput) - - @endif - @endif - - @if($showSocialProviderInfo) -
- {{ str_replace('__social_providers_list__', implode(', ', $userSocialProviders), config('devdojo.auth.language.login.social_auth_authenticated_message')) }} - -
- - @if(!config('devdojo.auth.settings.login_show_social_providers')) - - @endif - @endif - - @if($showPasswordField) - -
- {{ config('devdojo.auth.language.login.forget_password') }} -
- @endif - - - {{ config('devdojo.auth.language.login.button') }} - - - - -
- {{ config('devdojo.auth.language.login.dont_have_an_account') }} - {{ config('devdojo.auth.language.login.sign_up') }} -
- - @if(config('devdojo.auth.settings.login_show_social_providers') && config('devdojo.auth.settings.social_providers_location') != 'top') - - @endif - -
+ + @volt('auth.login') + + + + + + + @if(config('devdojo.auth.settings.login_show_social_providers') && config('devdojo.auth.settings.social_providers_location') == 'top') + + @endif + +
+ + @if($showPasswordField) + + + + @else + @if($showIdentifierInput) + + @endif + @endif + + @if($showSocialProviderInfo) +
+ {{ str_replace('__social_providers_list__', implode(', ', $userSocialProviders), config('devdojo.auth.language.login.social_auth_authenticated_message')) }} + +
+ + @if(!config('devdojo.auth.settings.login_show_social_providers')) + + @endif + @endif + + @if($showPasswordField) + +
+ {{ config('devdojo.auth.language.login.forget_password') }}
- @endvolt -
- + @endif + + + {{ config('devdojo.auth.language.login.button') }} + + + + +
+ {{ config('devdojo.auth.language.login.dont_have_an_account') }} + {{ config('devdojo.auth.language.login.sign_up') }} +
+ + @if(config('devdojo.auth.settings.login_show_social_providers') && config('devdojo.auth.settings.social_providers_location') != 'top') + + @endif + + + @endvolt + + \ No newline at end of file From 4d1a51d4a7a5e8219ad7cb436d2cfbe721e8cb45 Mon Sep 17 00:00:00 2001 From: skdishansachin Date: Wed, 3 Jul 2024 14:04:56 +0530 Subject: [PATCH 2/2] formate code --- resources/views/pages/auth/login.blade.php | 134 +++++++++++---------- 1 file changed, 70 insertions(+), 64 deletions(-) diff --git a/resources/views/pages/auth/login.blade.php b/resources/views/pages/auth/login.blade.php index 1b29466..69085a9 100644 --- a/resources/views/pages/auth/login.blade.php +++ b/resources/views/pages/auth/login.blade.php @@ -6,7 +6,7 @@ use Livewire\Volt\Component; use Devdojo\Auth\Traits\HasConfigs; -if (!isset($_GET['preview']) || (isset($_GET['preview']) && $_GET['preview'] != true) || !app()->isLocal()) { +if(!isset($_GET['preview']) || (isset($_GET['preview']) && $_GET['preview'] != true) || !app()->isLocal()){ middleware(['guest']); } @@ -35,20 +35,18 @@ public $userModel = null; - public function mount() - { + public function mount(){ $this->loadConfigs(); $this->twoFactorEnabled = $this->settings->enable_2fa; $this->userModel = app(config('auth.providers.users.model')); } - public function editIdentity() - { - if ($this->showPasswordField) { + public function editIdentity(){ + if($this->showPasswordField){ $this->showPasswordField = false; return; } - + $this->showIdentifierInput = true; $this->showSocialProviderInfo = false; } @@ -56,14 +54,14 @@ public function editIdentity() public function authenticate() { - if (!$this->showPasswordField) { + if(!$this->showPasswordField){ $this->validateOnly('email'); $userTryingToValidate = $this->userModel->where('email', $this->email)->first(); - if (!is_null($userTryingToValidate)) { - if (is_null($userTryingToValidate->password)) { + if(!is_null($userTryingToValidate)){ + if(is_null($userTryingToValidate->password)){ $this->userSocialProviders = []; // User is attempting to login and password is null. Need to show Social Provider info - foreach ($userTryingToValidate->socialProviders->all() as $provider) { + foreach($userTryingToValidate->socialProviders->all() as $provider){ array_push($this->userSocialProviders, $provider->provider_slug); } $this->showIdentifierInput = false; @@ -81,103 +79,111 @@ public function authenticate() $credentials = ['email' => $this->email, 'password' => $this->password]; - if (!\Auth::validate($credentials)) { + if(!\Auth::validate($credentials)){ $this->addError('password', trans('auth.failed')); return; } $userAttemptingLogin = $this->userModel->where('email', $this->email)->first(); - if (!isset($userAttemptingLogin->id)) { + if(!isset($userAttemptingLogin->id)){ $this->addError('password', trans('auth.failed')); return; } - if ($this->twoFactorEnabled && !is_null($userAttemptingLogin->two_factor_confirmed_at)) { + if($this->twoFactorEnabled && !is_null($userAttemptingLogin->two_factor_confirmed_at)){ // We want this user to login via 2fa session()->put([ 'login.id' => $userAttemptingLogin->getKey() ]); return redirect()->route('auth.two-factor-challenge'); + } else { if (!Auth::attempt($credentials)) { $this->addError('password', trans('auth.failed')); return; } - + event(new Login(auth()->guard('web'), $this->userModel->where('email', $this->email)->first(), true)); - if (session()->get('url.intended') != route('logout.get')) { + if(session()->get('url.intended') != route('logout.get')){ redirect()->intended(config('devdojo.auth.settings.redirect_after_auth')); } else { return redirect(config('devdojo.auth.settings.redirect_after_auth')); } } + } }; ?> - + @volt('auth.login') - - - - - + - @if(config('devdojo.auth.settings.login_show_social_providers') && config('devdojo.auth.settings.social_providers_location') == 'top') - - @endif + -
+ - @if($showPasswordField) - - - - @else - @if($showIdentifierInput) - - @endif + @if(config('devdojo.auth.settings.login_show_social_providers') && config('devdojo.auth.settings.social_providers_location') == 'top') + @endif - @if($showSocialProviderInfo) -
- {{ str_replace('__social_providers_list__', implode(', ', $userSocialProviders), config('devdojo.auth.language.login.social_auth_authenticated_message')) }} - + + + @if($showPasswordField) + + + + @else + @if($showIdentifierInput) + + @endif + @endif + + @if($showSocialProviderInfo) +
+ {{ str_replace('__social_providers_list__', implode(', ', $userSocialProviders), config('devdojo.auth.language.login.social_auth_authenticated_message')) }} + +
+ + @if(!config('devdojo.auth.settings.login_show_social_providers')) + + @endif + @endif + + @if($showPasswordField) + +
+ {{ config('devdojo.auth.language.login.forget_password') }} +
+ @endif + + + {{ config('devdojo.auth.language.login.button') }} + + + + +
+ {{ config('devdojo.auth.language.login.dont_have_an_account') }} + {{ config('devdojo.auth.language.login.sign_up') }}
- @if(!config('devdojo.auth.settings.login_show_social_providers')) - - @endif - @endif - - @if($showPasswordField) - -
- {{ config('devdojo.auth.language.login.forget_password') }} -
+ @if(config('devdojo.auth.settings.login_show_social_providers') && config('devdojo.auth.settings.social_providers_location') != 'top') + @endif - - {{ config('devdojo.auth.language.login.button') }} - - - - -
- {{ config('devdojo.auth.language.login.dont_have_an_account') }} - {{ config('devdojo.auth.language.login.sign_up') }} -
- - @if(config('devdojo.auth.settings.login_show_social_providers') && config('devdojo.auth.settings.social_providers_location') != 'top') - - @endif - - + @endvolt \ No newline at end of file