Commit 60b0e27
committed
feature #281 Throwing CustomUserMessageAuthenticationException in make:auth login (weaverryan)
This PR was merged into the 1.0-dev branch.
Discussion
----------
Throwing CustomUserMessageAuthenticationException in make:auth login
The idea is that this is easier and more self-documenting than teaching the user to translate the "Username could not be found." message.
```diff
// src/Security/LoginFormAuthenticator.php
// ...
public function getUser($credentials, UserProviderInterface $userProvider)
{
// ...
- return $this->entityManager->getRepository(User::class)->findOneBy([
+ $user = $this->entityManager->getRepository(User::class)->findOneBy([
'email' => $credentials['email'],
]);
+ if (!$user) {
+ // fail authentication with a custom error
+ throw new CustomUserMessageAuthenticationException('Email could not be found.');
+ }
+ return $user;
}
```
Cheers!
Commits
-------
5f9fead Throwing CustomUserMessageAuthenticationException in make:auth login formFile tree
3 files changed
+18
-3
lines changed- src
- Maker
- Resources/skeleton/authenticator
3 files changed
+18
-3
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
| 24 | + | |
24 | 25 | | |
25 | 26 | | |
26 | 27 | | |
| |||
237 | 238 | | |
238 | 239 | | |
239 | 240 | | |
| 241 | + | |
240 | 242 | | |
241 | 243 | | |
242 | 244 | | |
| |||
281 | 283 | | |
282 | 284 | | |
283 | 285 | | |
284 | | - | |
| 286 | + | |
285 | 287 | | |
286 | 288 | | |
287 | 289 | | |
| |||
Lines changed: 10 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
| 11 | + | |
11 | 12 | | |
12 | 13 | | |
13 | 14 | | |
| |||
63 | 64 | | |
64 | 65 | | |
65 | 66 | | |
66 | | - | |
| 67 | + | |
67 | 68 | | |
68 | 69 | | |
69 | | - | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
70 | 78 | | |
71 | 79 | | |
72 | 80 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
205 | 205 | | |
206 | 206 | | |
207 | 207 | | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
208 | 213 | | |
0 commit comments