1
0
mirror of https://github.com/LaCasemate/fab-manager.git synced 2025-01-08 23:46:14 +01:00
fab-manager/app/frontend/src/javascript/lib/user.ts
2021-06-30 15:32:10 +02:00

23 lines
500 B
TypeScript

import { User, UserRole } from '../models/user';
export default class UserLib {
private user: User;
constructor (user: User) {
this.user = user;
}
/**
* Check if the current user has privileged access for resources concerning the provided customer
*/
isPrivileged = (customer: User): boolean => {
if (this.user.role === UserRole.Admin) return true;
if (this.user.role === UserRole.Manager) {
return (this.user.id !== customer.id);
}
return false;
}
}