Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

check if obj is not null #2

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions server/services/admin/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ module.exports = {
},
onServerAdminFail: {
success: false,
message: 'This are is for admin users only'
message: 'This is for admin users only'
},
employeeAddedSuccessfully: {
success: true,
Expand All @@ -27,4 +27,4 @@ module.exports = {
success: false,
message: 'Please enter username and old or new password.'
}
}
}
5 changes: 3 additions & 2 deletions server/utils/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@ const Activities = require('../models/Activities');
const Employees = require('../models/Employees');

function checkUserControl(id) {

return new Promise((resolve, reject) => {
User.findOne({ _id: id }, (error, doc) => {
if (error) reject(error);
if (doc.role === 'Admin' || doc.role === 'admin') resolve(true);
if (doc && (doc.role === 'Admin' || doc.role === 'admin')) resolve(true);
reject({
success: false,
message: 'This is a restricted area and can only be access by Admins.'
Expand Down Expand Up @@ -35,4 +36,4 @@ module.exports = {
checkUserControl: checkUserControl,
setActivity: setActivity,
getUser: getUser
};
};