Merge branch 'develop' of Software_Engineering_I/greenvironment-server into master

pull/5/head
Trivernis 5 years ago committed by Gitea
commit f841eed341

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

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

Loading…
Cancel
Save