mirror of
https://github.com/Bubka/2FAuth.git
synced 2025-06-21 12:32:04 +02:00
Fix and test Redirection when already authenticated
This commit is contained in:
parent
48e3d22446
commit
20970606a3
@ -18,7 +18,7 @@ class RedirectIfAuthenticated
|
|||||||
public function handle($request, Closure $next, $guard = null)
|
public function handle($request, Closure $next, $guard = null)
|
||||||
{
|
{
|
||||||
if (Auth::guard($guard)->check()) {
|
if (Auth::guard($guard)->check()) {
|
||||||
return redirect('/home');
|
return response()->json(['message' => __('auth.already_authenticated')], 400);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $next($request);
|
return $next($request);
|
||||||
|
2
resources/js/langs/locales.js
vendored
2
resources/js/langs/locales.js
vendored
@ -6,6 +6,7 @@ export default {
|
|||||||
"register": "Register",
|
"register": "Register",
|
||||||
"hello": "Hi {username} !",
|
"hello": "Hi {username} !",
|
||||||
"throttle": "Too many login attempts. Please try again in {seconds} seconds.",
|
"throttle": "Too many login attempts. Please try again in {seconds} seconds.",
|
||||||
|
"already_authenticated": "Already authenticated",
|
||||||
"confirm": {
|
"confirm": {
|
||||||
"logout": "Are you sure you want to log out?"
|
"logout": "Are you sure you want to log out?"
|
||||||
},
|
},
|
||||||
@ -267,6 +268,7 @@ export default {
|
|||||||
"register": "Créer un compte",
|
"register": "Créer un compte",
|
||||||
"hello": "Hi {username} !",
|
"hello": "Hi {username} !",
|
||||||
"throttle": "Trop de tentatives de connexion. Veuillez réessayer dans {seconds} secondes.",
|
"throttle": "Trop de tentatives de connexion. Veuillez réessayer dans {seconds} secondes.",
|
||||||
|
"already_authenticated": "Déjà authentifié",
|
||||||
"confirm": {
|
"confirm": {
|
||||||
"logout": "Etes-vous sûrs de vouloir vous déconnecter ?"
|
"logout": "Etes-vous sûrs de vouloir vous déconnecter ?"
|
||||||
},
|
},
|
||||||
|
@ -18,6 +18,7 @@ return [
|
|||||||
'register' => 'Register',
|
'register' => 'Register',
|
||||||
'hello' => 'Hi {username} !',
|
'hello' => 'Hi {username} !',
|
||||||
'throttle' => 'Too many login attempts. Please try again in :seconds seconds.',
|
'throttle' => 'Too many login attempts. Please try again in :seconds seconds.',
|
||||||
|
'already_authenticated' => 'Already authenticated',
|
||||||
'confirm' => [
|
'confirm' => [
|
||||||
'logout' => 'Are you sure you want to log out?',
|
'logout' => 'Are you sure you want to log out?',
|
||||||
],
|
],
|
||||||
|
@ -18,6 +18,7 @@ return [
|
|||||||
'register' => 'Créer un compte',
|
'register' => 'Créer un compte',
|
||||||
'hello' => 'Hi {username} !',
|
'hello' => 'Hi {username} !',
|
||||||
'throttle' => 'Trop de tentatives de connexion. Veuillez réessayer dans :seconds secondes.',
|
'throttle' => 'Trop de tentatives de connexion. Veuillez réessayer dans :seconds secondes.',
|
||||||
|
'already_authenticated' => 'Déjà authentifié',
|
||||||
'confirm' => [
|
'confirm' => [
|
||||||
'logout' => 'Etes-vous sûrs de vouloir vous déconnecter ?',
|
'logout' => 'Etes-vous sûrs de vouloir vous déconnecter ?',
|
||||||
],
|
],
|
||||||
|
@ -46,6 +46,32 @@ class LoginTest extends TestCase
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* test User login via API
|
||||||
|
*
|
||||||
|
* @test
|
||||||
|
*/
|
||||||
|
public function testUserLoginAlreadyAuthenticated()
|
||||||
|
{
|
||||||
|
|
||||||
|
$response = $this->json('POST', '/api/login', [
|
||||||
|
'email' => $this->user->email,
|
||||||
|
'password' => 'password'
|
||||||
|
]);
|
||||||
|
|
||||||
|
$response = $this->actingAs($this->user, 'api')
|
||||||
|
->json('POST', '/api/login', [
|
||||||
|
'email' => $this->user->email,
|
||||||
|
'password' => 'password'
|
||||||
|
]);
|
||||||
|
|
||||||
|
$response->assertStatus(400)
|
||||||
|
->assertJson([
|
||||||
|
'message' => __('auth.already_authenticated')
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* test User login with missing values via API
|
* test User login with missing values via API
|
||||||
*
|
*
|
||||||
|
Loading…
x
Reference in New Issue
Block a user