File tree Expand file tree Collapse file tree 1 file changed +14
-2
lines changed Expand file tree Collapse file tree 1 file changed +14
-2
lines changed Original file line number Diff line number Diff line change @@ -166,13 +166,25 @@ class AuthService {
166166 // This closes the loophole where a non-admin user could request a code
167167 // via the app flow and then use it to log into the dashboard.
168168 if (isDashboardLogin) {
169+ if (user.email != email) {
170+ // This is a critical security check. If the user found by email
171+ // somehow has a different email than the one provided, it's a
172+ // sign of a serious issue (like the data layer bug we fixed).
173+ // We throw a generic error to avoid revealing information.
174+ _log.severe (
175+ 'CRITICAL: Mismatch between requested email ($email ) and found '
176+ 'user email (${user .email }) during dashboard login for user '
177+ 'ID ${user .id }.' ,
178+ );
179+ throw const UnauthorizedException ('User account does not exist.' );
180+ }
169181 if (! _permissionService.hasPermission (
170182 user,
171183 Permissions .dashboardLogin,
172184 )) {
173185 _log.warning (
174- 'Dashboard login failed: User ${user .id } lacks required permission '
175- 'during code verification.' ,
186+ 'Dashboard login failed: User ${user .id } lacks required '
187+ 'permission during code verification.' ,
176188 );
177189 throw const ForbiddenException (
178190 'Your account does not have the required permissions to sign in.' ,
You can’t perform that action at this time.
0 commit comments