forked from linnovate/mean
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathusers.js
80 lines (62 loc) · 2.41 KB
/
users.js
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
70
71
72
73
74
75
76
77
78
79
80
'use strict';
// User routes use users controller
var users = require('../controllers/users');
module.exports = function(app, passport) {
app.get('/logout', users.signout);
app.get('/users/me', users.me);
// Setting up the users api
app.post('/register', users.create);
// Setting up the userId param
app.param('userId', users.user);
// AngularJS route to check for authentication
app.get('/loggedin', function(req, res) {
res.send(req.isAuthenticated() ? req.user : '0');
});
// Setting the local strategy route
app.post('/login', passport.authenticate('local', {
failureFlash: true
}), function (req,res) {
res.send(req.user);
});
// Setting the facebook oauth routes
app.get('/auth/facebook', passport.authenticate('facebook', {
scope: ['email', 'user_about_me'],
failureRedirect: '#!/login'
}), users.signin);
app.get('/auth/facebook/callback', passport.authenticate('facebook', {
failureRedirect: '#!/login'
}), users.authCallback);
// Setting the github oauth routes
app.get('/auth/github', passport.authenticate('github', {
failureRedirect: '#!/login'
}), users.signin);
app.get('/auth/github/callback', passport.authenticate('github', {
failureRedirect: '#!/login'
}), users.authCallback);
// Setting the twitter oauth routes
app.get('/auth/twitter', passport.authenticate('twitter', {
failureRedirect: '#!/login'
}), users.signin);
app.get('/auth/twitter/callback', passport.authenticate('twitter', {
failureRedirect: '#!/login'
}), users.authCallback);
// Setting the google oauth routes
app.get('/auth/google', passport.authenticate('google', {
failureRedirect: '#!/login',
scope: [
'https://www.googleapis.com/auth/userinfo.profile',
'https://www.googleapis.com/auth/userinfo.email'
]
}), users.signin);
app.get('/auth/google/callback', passport.authenticate('google', {
failureRedirect: '#!/login'
}), users.authCallback);
// Setting the linkedin oauth routes
app.get('/auth/linkedin', passport.authenticate('linkedin', {
failureRedirect: '#!/login',
scope: [ 'r_emailaddress' ]
}), users.signin);
app.get('/auth/linkedin/callback', passport.authenticate('linkedin', {
failureRedirect: '#!/login'
}), users.authCallback);
};