Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- socket.on('auth', function(data){
- authlogin = data.login;
- authpassword = data.password;
- MongoClient.connect('mongodb://127.0.0.1:27017/test', function(err, db) {
- if(err) throw err;
- var collection = db.collection('accounts');
- collection.find({login: authlogin, password: authpassword}).toArray(function (err, result) {
- if (err) {
- console.log(err);
- } else if (result.length) {
- permission = 1;
- user = {"login": result[0].login, "mail": result[0].mail}
- console.log(user);
- def.writeHead(404, {'Content-Type': 'text/plain'}); // <- redirect
- def.write("Looked everywhere, but couldn't find that page at all!\n"); // <- content!
- def.end();
- } else {
- socket.emit('auth', {'state': 'false'});
- }
- //Close connection
- db.close();
- });
- });
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement