mirror of
https://github.com/wekan/wekan.git
synced 2025-12-18 00:10:13 +01:00
Added a simple authorization function
This commit is contained in:
parent
1bdc28bf9c
commit
ef6f2e8d62
1 changed files with 12 additions and 0 deletions
|
|
@ -27,5 +27,17 @@ Meteor.startup(() => {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// An admin should be authorized to access everything, so we use a separate check for admins
|
||||||
|
// This throws an error if otherReq is false and the user is not an admin
|
||||||
|
Authentication.checkAdminOrCondition = function(userId, otherReq) {
|
||||||
|
if(otherReq) return;
|
||||||
|
const admin = Users.findOne({ _id: userId, isAdmin: true });
|
||||||
|
if (admin === undefined) {
|
||||||
|
const error = new Meteor.Error('Forbidden', 'Forbidden');
|
||||||
|
error.statusCode = 403;
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue