32 lines
1.0 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

const RoleConfig: { [key: string]: UserRole } = {
'Education Technology Service Office': 'root',
'RO': 'ro',
'FO': 'fo',
}
/*
ETSO: 超级管理员用户名michaeldingkennytan
RO 现场支付和查看用户名kittyho, tlhoo, fredacheng
FO2现场支付和查看用户名ancuscheng
FO全部权限用户名ceciliachansylamjackoyeung
STAFF: 现场支付
*/
const UserRoles: { [key: string]: string[] } = {
'root': ['michaelding', 'kennytan','itsotest010'],
'ro': ['kittyho', 'ancuscheng','tlhoo','fredacheng'],
'fo': ['ceciliachan', 'sylam', 'jackoyeung'],
}
export function getRoleByDepartName(departName?: string, defaultRole: UserRole = 'staff') {
return (departName ? (RoleConfig[departName] || defaultRole) : defaultRole);
}
export function getRoleByUsername(username: string, defaultRole: UserRole = 'staff') {
const roles = ['root', 'ro', 'fo'];
for (const r of roles) {
if (UserRoles[r].includes(username.toLowerCase())) {
return r as UserRole;
}
}
return defaultRole;
}