The communications platform that puts data protection first.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
Rocket.Chat/apps/meteor/app/authorization/client/hasRole.ts

19 lines
707 B

import type { IUser, IRole, IRoom } from '@rocket.chat/core-typings';
import { Roles } from '../../models/client';
export const hasRole = (userId: IUser['_id'], roleId: IRole['_id'], scope?: IRoom['_id'], ignoreSubscriptions = false): boolean => {
if (Array.isArray(roleId)) {
throw new Error('error-invalid-arguments');
}
return Roles.isUserInRoles(userId, [roleId], scope, ignoreSubscriptions);
};
export const hasAnyRole = (userId: IUser['_id'], roleIds: IRole['_id'][], scope?: IRoom['_id'], ignoreSubscriptions = false): boolean => {
if (!Array.isArray(roleIds)) {
throw new Error('error-invalid-arguments');
}
return Roles.isUserInRoles(userId, roleIds, scope, ignoreSubscriptions);
};