Backend for the tags staff on staff users.

This commit is contained in:
gaba
2017-02-07 16:31:39 -08:00
parent 604a3a42b9
commit fc880de9bf
3 changed files with 23 additions and 0 deletions
+9
View File
@@ -9,6 +9,11 @@ const STATUSES = [
null
];
const TAGS = [
'STAFF',
null
];
/**
* The Mongo schema for a Comment Status.
* @type {Schema}
@@ -49,6 +54,10 @@ const CommentSchema = new Schema({
author_id: String,
status_history: [StatusSchema],
status: {type: String, default: null},
tag: {
type: String,
enum: TAGS,
},
parent_id: String
}, {
timestamps: {
+3
View File
@@ -3,6 +3,8 @@ const CommentModel = require('../models/comment');
const ActionModel = require('../models/action');
const ActionsService = require('./actions');
const UsersService = require('./users');
module.exports = class CommentsService {
/**
@@ -34,6 +36,7 @@ module.exports = class CommentsService {
created_at: new Date()
}] : [],
status,
tag: UsersService.isStaff(author_id) ? 'STAFF' : null,
author_id
});
+11
View File
@@ -687,4 +687,15 @@ module.exports = class UsersService {
Promise.reject(new Error('You do not have permission to update your username.'));
});
}
/**
* Returns true if the user is staff.
* @param {String} id the id of the user to be enabled.
* @return {Promise}
*/
static isStaff(id) {
return UserModel.findById(id).then((user) => {
return user.hasRoles('ADMIN');
});
}
};