authentication.js 483 B

123456789101112131415161718192021
  1. Meteor.startup(() => {
  2. Authentication = {};
  3. Authentication.checkUserId = function (userId) {
  4. if (userId === undefined) {
  5. const error = new Meteor.Error('Unauthorized', 'Unauthorized');
  6. error.statusCode = 401;
  7. throw error;
  8. }
  9. const admin = Users.findOne({ _id: userId, isAdmin: true });
  10. if (admin === undefined) {
  11. const error = new Meteor.Error('Forbidden', 'Forbidden');
  12. error.statusCode = 403;
  13. throw error;
  14. }
  15. };
  16. });