ldap user

This commit is contained in:
2020-05-01 17:57:25 -04:00
parent 7d9ea08ec9
commit 607a5f33af
15 changed files with 349 additions and 135 deletions
+22
View File
@@ -19,6 +19,9 @@ const User = require('../utils/redis_model')({
}
});
User.backing = "redis";
User.add = async function(data) {
try{
data['password'] = await bcrypt.hash(data['password'], saltRounds);
@@ -78,6 +81,25 @@ User.invite = async function(){
}
};
User.login = async function(data){
try{
let user = await User.get(data);
let auth = await bcrypt.compare(data.password, user.password);
if(auth){
return user
}else{
throw this.errors.login();
}
}catch(error){
if (error == 'Authentication failure'){
throw this.errors.login()
}
throw error;
}
};
module.exports = {User};