File tree Expand file tree Collapse file tree 1 file changed +19
-0
lines changed Expand file tree Collapse file tree 1 file changed +19
-0
lines changed Original file line number Diff line number Diff line change @@ -157,6 +157,25 @@ class AuthService {
157
157
final existingUser = await _findUserByEmail (email);
158
158
if (existingUser != null ) {
159
159
user = existingUser;
160
+ // If this is a dashboard login, re-verify the user's dashboard role.
161
+ // This closes the loophole where a non-admin user could request a code
162
+ // via the app flow and then use it to log into the dashboard.
163
+ if (isDashboardLogin) {
164
+ final hasRequiredRole =
165
+ user.dashboardRole == DashboardUserRole .admin ||
166
+ user.dashboardRole == DashboardUserRole .publisher;
167
+
168
+ if (! hasRequiredRole) {
169
+ _log.warning (
170
+ 'Dashboard login failed: User ${user .id } lacks required roles '
171
+ 'during code verification.' ,
172
+ );
173
+ throw const ForbiddenException (
174
+ 'Your account does not have the required permissions to sign in.' ,
175
+ );
176
+ }
177
+ _log.info ('Dashboard user ${user .id } re-verified successfully.' );
178
+ }
160
179
} else {
161
180
// User not found.
162
181
if (isDashboardLogin) {
You can’t perform that action at this time.
0 commit comments