File tree Expand file tree Collapse file tree 4 files changed +29
-5
lines changed Expand file tree Collapse file tree 4 files changed +29
-5
lines changed Original file line number Diff line number Diff line change @@ -60,7 +60,7 @@ public function loginAction()
6060 // Validate email format
6161 $ rules = $ this ->getValidationRules ();
6262 if (! $ this ->validate ($ rules )) {
63- return redirect ()->route ('magic-link ' )->with ('error ' , lang ( ' Auth.invalidEmail ' ));
63+ return redirect ()->route ('magic-link ' )->with ('errors ' , $ this -> validator -> getErrors ( ));
6464 }
6565
6666 // Check if the user exists
Original file line number Diff line number Diff line change 99 <div class="card-body">
1010 <h5 class="card-title mb-5"><?= lang ('Auth.useMagicLink ' ) ?> </h5>
1111
12- <?php if (session ('error ' ) !== null ) : ?>
13- <div class="alert alert-danger" role="alert"><?= session ('error ' ) ?> </div>
14- <?php endif ?>
12+ <?php if (session ('error ' ) !== null ) : ?>
13+ <div class="alert alert-danger" role="alert"><?= session ('error ' ) ?> </div>
14+ <?php elseif (session ('errors ' ) !== null ) : ?>
15+ <div class="alert alert-danger" role="alert">
16+ <?php if (is_array (session ('errors ' ))) : ?>
17+ <?php foreach (session ('errors ' ) as $ error ) : ?>
18+ <?= $ error ?>
19+ <br>
20+ <?php endforeach ?>
21+ <?php else : ?>
22+ <?= session ('errors ' ) ?>
23+ <?php endif ?>
24+ </div>
25+ <?php endif ?>
1526
1627 <form action="<?= url_to ('magic-link ' ) ?> " method="post">
1728 <?= csrf_field () ?>
Original file line number Diff line number Diff line change @@ -50,7 +50,9 @@ public function testMagicLinkSubmitNoEmail(): void
5050 ]);
5151
5252 $ result ->assertRedirectTo (route_to ('magic-link ' ));
53- $ result ->assertSessionHas ('error ' , lang ('Auth.invalidEmail ' ));
53+ $ expected = ['email ' => 'The Email Address field is required. ' ];
54+
55+ $ result ->assertSessionHas ('errors ' , $ expected );
5456 }
5557
5658 public function testMagicLinkSubmitBadEmail (): void
Original file line number Diff line number Diff line change @@ -46,4 +46,15 @@ public function testAfterLoggedInNotAllowDisplayMagicLink()
4646 $ result = $ this ->get ('/login/magic-link ' );
4747 $ result ->assertRedirectTo (config ('Auth ' )->loginRedirect ());
4848 }
49+
50+ public function testShowValidateErrorsInMagicLink ()
51+ {
52+ $ result = $ this ->post ('/login/magic-link ' , [
53+ 'email ' => 'foo@example ' ,
54+ ]);
55+
56+ $ expected = ['email ' => 'The Email Address field must contain a valid email address. ' ];
57+
58+ $ result ->assertSessionHas ('errors ' , $ expected );
59+ }
4960}
You can’t perform that action at this time.
0 commit comments