const RoleConfig: { [key: string]: UserRole } = { 'Education Technology Service Office': 'root', 'RO': 'ro', 'FO': 'fo', } /* ETSO: 超级管理员,用户名:michaelding,kennytan RO: 现场支付和查看,用户名:kittyho, tlhoo, fredacheng FO2:现场支付和查看,用户名:ancuscheng FO:全部权限,用户名:ceciliachan,sylam,jackoyeung 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; }