Commit cca71a2
committed
feat(auth): make code request context-aware for dashboard login
Implements context-aware logic in the `AuthService.initiateEmailSignIn`
method.
- The method now accepts an `isDashboardLogin` boolean flag.
- If `isDashboardLogin` is true, the service first validates that a
user with the provided email exists and has either the 'admin' or
'publisher' role.
- An `UnauthorizedException` is thrown if the user does not exist.
- A `ForbiddenException` is thrown if the user exists but lacks the
required roles.
- A verification code is only sent if these checks pass.
- If `isDashboardLogin` is false, the original behavior of sending a
code without pre-validation is maintained for the user-facing app's
sign-in/sign-up flow.
This change enforces security at the first step of the dashboard login
process, preventing code generation for unauthorized users.1 parent 8bf722f commit cca71a2
1 file changed
+56
-2
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
41 | 41 | | |
42 | 42 | | |
43 | 43 | | |
44 | | - | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
45 | 55 | | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
46 | 60 | | |
47 | | - | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
48 | 65 | | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
49 | 103 | | |
50 | 104 | | |
51 | 105 | | |
| |||
0 commit comments