Skip to content

Commit

Permalink
Merge pull request #105 from Lakshan-Madushanka/feature-login-remembe…
Browse files Browse the repository at this point in the history
…r-me

Remember me feature for the login form
  • Loading branch information
tnylea authored Sep 20, 2024
2 parents 12824a2 + 5be791e commit 1398e66
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
1 change: 1 addition & 0 deletions config/devdojo/auth/language.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
'show_subheadline' => false,
'email_address' => 'Email Address',
'password' => 'Password',
'remember_me' => 'Remember me',
'edit' => 'Edit',
'button' => 'Continue',
'forget_password' => 'Forget your password?',
Expand Down
12 changes: 8 additions & 4 deletions resources/views/pages/auth/login.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@
#[Validate('required')]
public $password = '';
#[Validate('bool')]
public $rememberMe = false;
public $showPasswordField = false;
public $showIdentifierInput = true;
Expand All @@ -46,7 +49,7 @@ public function editIdentity(){
$this->showPasswordField = false;
return;
}
$this->showIdentifierInput = true;
$this->showSocialProviderInfo = false;
}
Expand Down Expand Up @@ -100,11 +103,11 @@ public function authenticate()
return redirect()->route('auth.two-factor-challenge');
} else {
if (!Auth::attempt($credentials)) {
if (!Auth::attempt($credentials, $this->rememberMe)) {
$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')){
Expand Down Expand Up @@ -165,7 +168,8 @@ 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" />
<div class="flex justify-between items-center mt-6 text-sm leading-5">
<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>
@endif
Expand Down

0 comments on commit 1398e66

Please sign in to comment.