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/server/methods/setUserActiveStatus.ts

38 lines
1.1 KiB

import { Meteor } from 'meteor/meteor';
import { check } from 'meteor/check';
import type { ServerMethods } from '@rocket.chat/ui-contexts';
import { hasPermissionAsync } from '../../app/authorization/server/functions/hasPermission';
import { setUserActiveStatus } from '../../app/lib/server/functions/setUserActiveStatus';
declare module '@rocket.chat/ui-contexts' {
// eslint-disable-next-line @typescript-eslint/naming-convention
interface ServerMethods {
setUserActiveStatus(userId: string, active: boolean, confirmRelinquish?: boolean): boolean;
}
}
Meteor.methods<ServerMethods>({
async setUserActiveStatus(userId, active, confirmRelinquish) {
check(userId, String);
check(active, Boolean);
if (!Meteor.userId()) {
throw new Meteor.Error('error-invalid-user', 'Invalid user', {
method: 'setUserActiveStatus',
});
}
const uid = Meteor.userId();
if (!uid || (await hasPermissionAsync(uid, 'edit-other-user-active-status')) !== true) {
throw new Meteor.Error('error-not-allowed', 'Not allowed', {
method: 'setUserActiveStatus',
});
}
await setUserActiveStatus(userId, active, confirmRelinquish);
return true;
},
});