(test for old input on failed login)

This commit is contained in:
Adam Wathan
2017-05-10 11:08:24 -04:00
parent 54d054214f
commit 9ad16a9434
3 changed files with 6 additions and 1 deletions

View File

@@ -16,7 +16,7 @@ class LoginController extends Controller
public function login()
{
if (! Auth::attempt(request(['email', 'password']))) {
return redirect('/login')->withErrors([
return redirect('/login')->withInput(request(['email']))->withErrors([
'email' => ['These credentials do not match our records.'],
]);
}

View File

@@ -42,6 +42,7 @@ class PromoterLoginTest extends DuskTestCase
->type('password', 'wrong-password')
->press('Log in')
->assertPathIs('/login')
->assertInputValue('email', 'jane@example.com')
->assertSee('credentials do not match');
});
}

View File

@@ -48,6 +48,8 @@ class PromoterLoginTest extends TestCase
$response->assertRedirect('/login');
$response->assertSessionHasErrors('email');
$this->assertTrue(session()->hasOldInput('email'));
$this->assertFalse(session()->hasOldInput('password'));
$this->assertFalse(Auth::check());
}
@@ -63,6 +65,8 @@ class PromoterLoginTest extends TestCase
$response->assertRedirect('/login');
$response->assertSessionHasErrors('email');
$this->assertTrue(session()->hasOldInput('email'));
$this->assertFalse(session()->hasOldInput('password'));
$this->assertFalse(Auth::check());
}
}