fix(GRO-634): atomic confirmation token in book.ts, correct RBAC error message
- Replace SELECT-then-UPDATE with atomic UPDATE ... WHERE token=? AND status='pending' RETURNING * to prevent confirmation token replay attacks (TOCTOU race condition) - Fix requireRoleOrSuperUser() error message: swap the conditional branches so 'Forbidden: super user privileges required' is returned when user lacks role, and 'Forbidden: role X is not permitted' when user is not superuser - Add 'and' mock export to confirmation.test.ts and rbac.test.ts for new query patterns - Update test expectations to match corrected error message semantics
This commit is contained in:
@@ -149,9 +149,9 @@ export function requireRoleOrSuperUser(
|
||||
}
|
||||
return c.json(
|
||||
{
|
||||
error: staffRow.isSuperUser
|
||||
? `Forbidden: role '${staffRow.role}' is not permitted`
|
||||
: "Forbidden: super user privileges required",
|
||||
error: hasAllowedRole
|
||||
? "Forbidden: super user privileges required"
|
||||
: `Forbidden: role '${staffRow.role}' is not permitted`,
|
||||
},
|
||||
403
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user