Skip to content

Commit

Permalink
Merge branch 'rc' of github.com:FabMo/FabMo-Updater into rc
Browse files Browse the repository at this point in the history
  • Loading branch information
wholetthedogsout committed Sep 6, 2018
2 parents f236bd2 + 16b6c49 commit 20ec0a1
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 8 deletions.
21 changes: 14 additions & 7 deletions authentication.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ exports.configure = function(){
if(!data.isAdmin){
return done(null, false, { message: 'Must be admin' });
}

console.log('configure');
var user = {
'username': username,
'password': data.password,
Expand Down Expand Up @@ -109,6 +109,7 @@ exports.configure = function(){
};

var addUser = function(username,password,callback){
console.log('adduser');
config.user.add(username,password,function(err,user){
if(err){
callback(err);
Expand Down Expand Up @@ -209,6 +210,7 @@ var modifyUser = function(username, user_fields,callback){
}
}
config.user.update(newData, function(err,user){
console.log('hey');
if(user)user.password=undefined; // don't transmit the password back
callback(err,user);
return;
Expand All @@ -233,13 +235,17 @@ passport.serializeUser(function(user, done) {

passport.deserializeUser(function(username, done) {
config.user.findOne(username, function(err, data) {
var user = {
'username': username,
'password': data.password,
'isAdmin' : data.isAdmin,
'created_at': data.created_at
if(err) {
done(null, false, { message: 'User does not exist' });
}else {
var user = {
'username': username,
'password': data.password,
'isAdmin' : data.isAdmin,
'created_at': data.created_at
}
done(err, user);
}
done(err, user);
});
});

Expand All @@ -254,6 +260,7 @@ exports.deleteUser = deleteUser;
exports.passport = passport;

exports.getUserById = function(username,cb){
console.log('getUserById');
config.user.findOne(username, function(err, data) {
var user = {
'username': username,
Expand Down
2 changes: 1 addition & 1 deletion config/user_config.js
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ UserConfig.prototype.add = function(username,password,callback){

//Maybe move this to the routes or whatever
UserConfig.prototype.findOne = function(username,callback){
username in this._cache ? callback(null, this._cache[username]) : callback(null, null);
username in this._cache ? callback(null, this._cache[username]) : callback('no user', null);
}

UserConfig.prototype.getAll = function(callback){
Expand Down

0 comments on commit 20ec0a1

Please sign in to comment.