forked from nrkno/sofie-core
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
63 additions
and
63 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
export const USER_PERMISSIONS_HEADER = 'dnt' | ||
// export const USER_LEVEL_USER_ID = protectString<UserId>('fake-user') | ||
|
||
export interface UserPermissions { | ||
studio: boolean | ||
configure: boolean | ||
developer: boolean | ||
testing: boolean | ||
service: boolean | ||
} | ||
const allowedPermissions = new Set<keyof UserPermissions>(['studio', 'configure', 'developer', 'testing', 'service']) | ||
|
||
export function parseUserPermissions(encodedPermissions: string | undefined): UserPermissions | null { | ||
if (encodedPermissions === 'admin') { | ||
return { | ||
studio: true, | ||
configure: true, | ||
developer: true, | ||
testing: true, | ||
service: true, | ||
} | ||
} | ||
|
||
const result: UserPermissions = { | ||
studio: false, | ||
configure: false, | ||
developer: false, | ||
testing: false, | ||
service: false, | ||
} | ||
|
||
if (encodedPermissions && typeof encodedPermissions === 'string') { | ||
const parts = encodedPermissions.split(',') | ||
|
||
for (const part of parts) { | ||
const part2 = part.trim() as keyof UserPermissions | ||
if (allowedPermissions.has(part2)) { | ||
result[part2] = true | ||
} | ||
} | ||
|
||
return result | ||
} | ||
|
||
return null | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters