case 4713 - customer contacts hold and act with customer roles only
Users who may edit contacts but not users (Service, Sales, Accounting) could give a contact login any role, BizAdmin and OpsAdmin included, and roles are what every check uses (security review F28). Now: - saving a Customer or HeadOffice user with any role other than Customer or CustomerRestricted is refused (error on Roles); - UserBiz.EffectiveRoles masks a contact's roles to the customer roles wherever they are applied: the token middleware, download-key routes, and the notification subscriber check, so contacts that already have staff roles stored act without them. Checked: Service creating a contact with BizAdmin refused, with Customer works; a contact with OpsAdmin stored in the database gets 403 downloading a log file. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -406,7 +406,8 @@ namespace AyaNova
|
||||
|
||||
//get the user record
|
||||
var u = await ct.User.AsNoTracking().Where(a => a.Id == userId).Select(m => new { roles = m.Roles, name = m.Name, m.UserType, id = m.Id, translationId = m.UserOptions.TranslationId, currentAuthToken = m.CurrentAuthToken }).FirstAsync();
|
||||
context.Request.HttpContext.Items["AY_ROLES"] = u.roles;
|
||||
//case 4713: a customer contact acts only with the customer roles, whatever roles are stored
|
||||
context.Request.HttpContext.Items["AY_ROLES"] = UserBiz.EffectiveRoles(u.UserType, u.roles);
|
||||
context.Request.HttpContext.Items["AY_USERNAME"] = u.name;
|
||||
context.Request.HttpContext.Items["AY_USER_ID"] = u.id;
|
||||
context.Request.HttpContext.Items["AY_TRANSLATION_ID"] = u.translationId;
|
||||
|
||||
Reference in New Issue
Block a user