summaryrefslogtreecommitdiff
path: root/server/auth/index.js
diff options
context:
space:
mode:
Diffstat (limited to 'server/auth/index.js')
-rw-r--r--server/auth/index.js17
1 files changed, 10 insertions, 7 deletions
diff --git a/server/auth/index.js b/server/auth/index.js
index 37b023f..b15094d 100644
--- a/server/auth/index.js
+++ b/server/auth/index.js
@@ -12,27 +12,31 @@ var auth = {
guestUser: {
id: "guest",
username: "guest",
+ access: 0,
},
init: function () {
passport.serializeUser(auth.serializeUser);
passport.deserializeUser(auth.deserializeUser);
-
passport.use(new LocalStrategy(auth.verifyLocalUser))
},
login: function (req, res, next) {
passport.authenticate("local", function(err, user, info){
- if (err) {
+ if (err || ! user) {
return res.json({ error: err });
}
- if (! user) {
- return info ? res.json(info) : res.redirect("/login");
- }
req.logIn(user, function(err) {
if (err) { return next(err); }
- return res.json({ status: "OK", user: user, returnTo: returnTo || "/profile" })
+ User.findAll({ where: { access: 2 }, attributes: ['id','name'] }).success(function(hosts){
+ return res.json({
+ status: "OK",
+ user: user,
+ hosts: hosts,
+ returnTo: returnTo || "/profile"
+ })
+ })
});
})(req, res, next);
},
@@ -58,7 +62,6 @@ var auth = {
verifyLocalUser: function (username, password, done) {
if (username == "protocolsnyc" && password == "madhousenyc") {
return done(null, auth.guestUser)
- return
}
User.findByUsername(username, function(err, user){
if (err) { return done(err); }