Skip to content

Commit

Permalink
Merge pull request #20 from thedevdojo/updateUerModel
Browse files Browse the repository at this point in the history
Update uer model
  • Loading branch information
tnylea authored May 24, 2024
2 parents 011c918 + 70bdd67 commit 904f24e
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 6 deletions.
6 changes: 5 additions & 1 deletion resources/views/pages/auth/login.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,11 @@ public function authenticate()
}
event(new Login(auth()->guard('web'), User::where('email', $this->email)->first(), true));
return redirect()->intended('/');
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'));
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion resources/views/pages/auth/password/confirm.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public function confirm()
session()->put('auth.password_confirmed_at', time());
return redirect()->intended('/');
return redirect()->intended(config('devdojo.auth.settings.redirect_after_auth'));
}
};
Expand Down
6 changes: 5 additions & 1 deletion resources/views/pages/auth/register.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,11 @@ public function register()
return redirect()->route('verification.notice');
}
return redirect()->intended(config('devdojo.auth.settings.redirect_after_auth'));
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'));
}
}
};
Expand Down
8 changes: 7 additions & 1 deletion resources/views/pages/auth/two-factor-challenge.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,13 @@ public function submitCode($code)
session()->forget('login.id');
event(new Login(auth()->guard('web'), $user, true));
return redirect()->intended('/');
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'));
}
} else {
dd('invalid');
}
Expand Down
8 changes: 8 additions & 0 deletions src/Http/Controllers/LogoutController.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,12 @@ public function __invoke(): RedirectResponse

return redirect()->route('home');
}

public function getLogout()
{
Auth::logout();
Session()->flush();

return redirect('/');
}
}
4 changes: 2 additions & 2 deletions tests/Feature/TwoFactorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
->set('password', 'password123')
->call('authenticate')
->assertHasNoErrors()
->assertRedirect('/');
->assertRedirect('dashboard');

$this->assertTrue(! Session::has('login.id'));
});
Expand Down Expand Up @@ -58,7 +58,7 @@
->set('password', 'password123')
->call('authenticate')
->assertHasNoErrors()
->assertRedirect('/');
->assertRedirect('dashboard');
});

it('user cannot view two factor challenge page logging in if it\'s disabled', function () {
Expand Down

0 comments on commit 904f24e

Please sign in to comment.