-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathauth.js
More file actions
37 lines (27 loc) · 1.01 KB
/
auth.js
File metadata and controls
37 lines (27 loc) · 1.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
var MongoClient = require('mongodb').MongoClient;
var url = 'mongodb://mongoclient:mongoclient@ds041861.mongolab.com:41861/app';
exports.localAuth = function(username, password, done) {
console.log('username:' + username);
console.log('password:' + password);
MongoClient.connect(url,function(err,db){
if(err){throw err};
db.collection('account').findOne({username:username},function(err,doc){
if (err) {console.log(err);throw err};
if (doc.password == password){ return done(null,doc.username)}
return done(null,false);
})
})
/*for(i=0;i<users.length;i++){
if (username == users[i].username){
if(password == users[i].password){
return done(null,username);
}
users[i].isAuthenticated = false;
return done(null,false,{message:'Invalid password'});
}
}
return done(null,false,{message:'Invalid user'});*/
}
var users = [ {username:"a@a.com",password:"manikanth"},
{username:"b@b.com",password:"mithra"}
];