Clean up role header implementation in currentapp.ts
This commit is contained in:
parent
f3d54f1b7d
commit
cf3ef64734
|
@ -56,22 +56,9 @@ export default async (ctx: UserCtx, next: any) => {
|
||||||
ctx.request &&
|
ctx.request &&
|
||||||
(ctx.request.headers[constants.Header.PREVIEW_ROLE] as string)
|
(ctx.request.headers[constants.Header.PREVIEW_ROLE] as string)
|
||||||
if (isBuilder && isDevApp && roleHeader) {
|
if (isBuilder && isDevApp && roleHeader) {
|
||||||
// Ensure the role is valid by ensuring a definition exists
|
roleId = roleHeader
|
||||||
try {
|
// Delete admin and builder flags so that the specified role is honoured
|
||||||
if (roleHeader) {
|
ctx.user = users.removePortalUserPermissions(ctx.user) as ContextUser
|
||||||
const role = await roles.getRole(roleHeader)
|
|
||||||
if (role) {
|
|
||||||
roleId = roleHeader
|
|
||||||
|
|
||||||
// Delete admin and builder flags so that the specified role is honoured
|
|
||||||
ctx.user = users.removePortalUserPermissions(
|
|
||||||
ctx.user
|
|
||||||
) as ContextUser
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (error) {
|
|
||||||
// Swallow error and do nothing
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue