Skip to content

Commit

Permalink
Fix active user issue for projects
Browse files Browse the repository at this point in the history
  • Loading branch information
mboudet committed Feb 6, 2024
1 parent 06469d0 commit 8ae6d92
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
5 changes: 5 additions & 0 deletions core/user.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ exports.remove_user_from_project = remove_user_from_project;
exports.activate_user = activate_user;
exports.new_password = new_password;
exports.new_random = new_random;
exports.is_active = is_active;

function new_random(len=16) {
return crypto.randomBytes(32).toString('hex').slice(0,len);
Expand All @@ -59,6 +60,10 @@ function new_password(len=16) {
});
}

function is_active(user){
return user.status === STATUS_ACTIVE;
}

// module functions
function get_user_home(user) {
if (!user.uid || user.uid.length <= 1) {
Expand Down
6 changes: 6 additions & 0 deletions routes/projects.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,12 @@ router.post('/project', async function(req, res){
res.status(404).send({message: 'Owner not found'});
return;
}

if (!usrsrv.is_active(owner)) {
res.status(403).send({message: 'Owner account is not active'});
return;
}

let project = await dbsrv.mongo_projects().findOne({'id': req.body.id});
if(project){
res.status(403).send({message: 'Not authorized or project already exists'});
Expand Down

0 comments on commit 8ae6d92

Please sign in to comment.