refactoring register to use form post instead of socket (for passport integration)

This commit is contained in:
Julian Lam
2013-05-02 10:15:55 -04:00
parent 4c80e4f37d
commit 69bafcf19c
5 changed files with 27 additions and 46 deletions

View File

@@ -164,6 +164,20 @@ passport.deserializeUser(function(uid, done) {
res.send(templates['header'] + templates['register'] + templates['footer']);
});
app.post('/register', function(req, res) {
global.modules.user.create(req.body.username, req.body.password, req.body.email, function(err, uid) {
if (err === null) {
req.login({
uid: uid
}, function() {
res.redirect('/');
});
} else {
res.redirect('/register');
}
});
});
app.get('/account', function(req, res) {
refreshTemplates();
res.send(templates['header'] + templates['account_settings'] + templates['footer']);