Skip to content

Commit a0c491a

Browse files
committed
feat(v1-contexts): Added isAdmin/isManager flags to user/current context
1 parent a3e8f1f commit a0c491a

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

packages/v1-contexts/src/common/user/current.ts

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import type { Schema } from '~types/user/current'
77

88
import {
99
arrayOf,
10+
isBoolean,
1011
isNull,
1112
isNumber,
1213
isString,
@@ -56,6 +57,16 @@ export const schema: Schema = {
5657
defaults: (): string[] => [],
5758
readonly: true,
5859
},
60+
'isAdmin': {
61+
accepts: isBoolean,
62+
defaults: () => false,
63+
readonly: true,
64+
},
65+
'isManager': {
66+
accepts: isBoolean,
67+
defaults: () => false,
68+
readonly: true,
69+
},
5970
}
6071

6172
export const description: ContextSchemaDescription<Schema> = {
@@ -115,6 +126,20 @@ export const description: ContextSchemaDescription<Schema> = {
115126
'ru-RU': 'Символьные коды доступных пользователю разрешений',
116127
},
117128
},
129+
'isAdmin': {
130+
description: {
131+
'en-GB': 'Indicates whether the user has administrator privileges',
132+
'es-ES': 'Indica si el usuario tiene privilegios de administrador',
133+
'ru-RU': 'Указывает, имеет ли пользователь права администратора',
134+
},
135+
},
136+
'isManager': {
137+
description: {
138+
'en-GB': 'Indicates whether the user has manager privileges',
139+
'es-ES': 'Indica si el usuario tiene privilegios de gerente',
140+
'ru-RU': 'Указывает, имеет ли пользователь права менеджера',
141+
},
142+
},
118143
}
119144

120145
export const usage: ContextSchemaUsage = {

packages/v1-contexts/types/user/current.d.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,6 @@ export type Schema = {
99
'photo': ReadonlyField<string | null>;
1010
'groups': ReadonlyField<string[]>;
1111
'permissions': ReadonlyField<string[]>;
12+
'isAdmin': ReadonlyField<boolean>;
13+
'isManager': ReadonlyField<boolean>;
1214
}

0 commit comments

Comments
 (0)