Allow admins to delete groups

pull/5/head
Trivernis 5 years ago
parent 16e9d9def5
commit f213503c4e

@ -86,7 +86,7 @@ export class Event extends Model<Event> {
if (userId) {
const group = await this.$get<Group>("rGroup") as Group;
const user = await User.findByPk(userId);
return group.$has("rAdmins", user);
return (await group.$has("rAdmins", user)) || user.isAdmin;
} else {
return false;
}

@ -153,7 +153,8 @@ export class Group extends Model<Group> {
public async deletable({userId}: { userId?: number }, request: any): Promise<boolean> {
userId = userId ?? request.session.userId;
if (userId) {
return this.creatorId === userId;
const user = await User.findByPk(userId);
return this.creatorId === userId || user.isAdmin;
} else {
return false;
}

Loading…
Cancel
Save