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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
|
/**
* Module dependencies
*/
var mongoose = require('mongoose')
, User = mongoose.model('User');
/**
* Login
*/
exports.login = function(req, res) {
res.render('login', {
title: 'Login'
});
}
/**
* Logout
*/
exports.logout = function(req, res) {
req.logout();
res.redirect('/test');
}
/**
* Signin
* This is triggered when the user post to /login
*/
exports.signin = function(req, res) {
res.redirect('/dashboard');
}
/**
* Signup
*/
exports.signup = function(req, res) {
res.render('signup', { title: 'Registrer deg' });
}
/**
* Create users
*/
exports.create = function(req, res) {
var user = new User(req.body);
user.provider = 'local';
user.save(function(err) {
if (err) return res.render('signup', { errors: err.errors, user: user });
req.logIn(user, function(err) {
if (err) return next(err);
return res.redirect('/dashboard');
});
});
}
/**
* AuthCallback
* This is what happends when a user has signed in using facebook/twitter
*/
exports.authCallback = function(req, res, next) {
res.redirect('/dashboard');
}
|