Skip to content

Commit 838b98e

Browse files
committed
Fix typo
1 parent 4b67bed commit 838b98e

File tree

11 files changed

+397
-397
lines changed

11 files changed

+397
-397
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,4 @@ npm-debug.log
1515
node_modules
1616

1717
config/secretDatabase.js
18-
config/secretAuth.js
18+
config/secretAuth.js

app/models/user.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ var userSchema = mongoose.Schema({
77

88
local : {
99
email : String,
10-
password : String,
10+
password : String
1111
},
1212
facebook : {
1313
id : String,

app/routes.js

Lines changed: 155 additions & 155 deletions
Original file line numberDiff line numberDiff line change
@@ -2,142 +2,142 @@ module.exports = function(app, passport) {
22

33
// normal routes ===============================================================
44

5-
// show the home page (will also have our login links)
6-
app.get('/', function(req, res) {
7-
res.render('index.ejs');
8-
});
9-
10-
// PROFILE SECTION =========================
11-
app.get('/profile', isLoggedIn, function(req, res) {
12-
res.render('profile.ejs', {
13-
user : req.user
14-
});
15-
});
16-
17-
// LOGOUT ==============================
18-
app.get('/logout', function(req, res) {
19-
req.logout();
20-
res.redirect('/');
21-
});
5+
// show the home page (will also have our login links)
6+
app.get('/', function(req, res) {
7+
res.render('index.ejs');
8+
});
9+
10+
// PROFILE SECTION =========================
11+
app.get('/profile', isLoggedIn, function(req, res) {
12+
res.render('profile.ejs', {
13+
user : req.user
14+
});
15+
});
16+
17+
// LOGOUT ==============================
18+
app.get('/logout', function(req, res) {
19+
req.logout();
20+
res.redirect('/');
21+
});
2222

2323
// =============================================================================
2424
// AUTHENTICATE (FIRST LOGIN) ==================================================
2525
// =============================================================================
2626

27-
// locally --------------------------------
28-
// LOGIN ===============================
29-
// show the login form
30-
app.get('/login', function(req, res) {
31-
res.render('login.ejs', { message: req.flash('loginMessage') });
32-
});
33-
34-
// process the login form
35-
app.post('/login', passport.authenticate('local-login', {
36-
successRedirect : '/profile', // redirect to the secure profile section
37-
failureRedirect : '/login', // redirect back to the signup page if there is an error
38-
failureFlash : true // allow flash messages
39-
}));
40-
41-
// SIGNUP =================================
42-
// show the signup form
43-
app.get('/signup', function(req, res) {
44-
res.render('signup.ejs', { message: req.flash('signupMessage') });
45-
});
46-
47-
// process the signup form
48-
app.post('/signup', passport.authenticate('local-signup', {
49-
successRedirect : '/profile', // redirect to the secure profile section
50-
failureRedirect : '/signup', // redirect back to the signup page if there is an error
51-
failureFlash : true // allow flash messages
52-
}));
53-
54-
// facebook -------------------------------
55-
56-
// send to facebook to do the authentication
57-
app.get('/auth/facebook', passport.authenticate('facebook', { scope : 'email' }));
58-
59-
// handle the callback after facebook has authenticated the user
60-
app.get('/auth/facebook/callback',
61-
passport.authenticate('facebook', {
62-
successRedirect : '/profile',
63-
failureRedirect : '/'
64-
}));
65-
66-
// twitter --------------------------------
67-
68-
// send to twitter to do the authentication
69-
app.get('/auth/twitter', passport.authenticate('twitter', { scope : 'email' }));
70-
71-
// handle the callback after twitter has authenticated the user
72-
app.get('/auth/twitter/callback',
73-
passport.authenticate('twitter', {
74-
successRedirect : '/profile',
75-
failureRedirect : '/'
76-
}));
77-
78-
79-
// google ---------------------------------
80-
81-
// send to google to do the authentication
82-
app.get('/auth/google', passport.authenticate('google', { scope : ['profile', 'email'] }));
83-
84-
// the callback after google has authenticated the user
85-
app.get('/auth/google/callback',
86-
passport.authenticate('google', {
87-
successRedirect : '/profile',
88-
failureRedirect : '/'
89-
}));
27+
// locally --------------------------------
28+
// LOGIN ===============================
29+
// show the login form
30+
app.get('/login', function(req, res) {
31+
res.render('login.ejs', { message: req.flash('loginMessage') });
32+
});
33+
34+
// process the login form
35+
app.post('/login', passport.authenticate('local-login', {
36+
successRedirect : '/profile', // redirect to the secure profile section
37+
failureRedirect : '/login', // redirect back to the signup page if there is an error
38+
failureFlash : true // allow flash messages
39+
}));
40+
41+
// SIGNUP =================================
42+
// show the signup form
43+
app.get('/signup', function(req, res) {
44+
res.render('signup.ejs', { message: req.flash('signupMessage') });
45+
});
46+
47+
// process the signup form
48+
app.post('/signup', passport.authenticate('local-signup', {
49+
successRedirect : '/profile', // redirect to the secure profile section
50+
failureRedirect : '/signup', // redirect back to the signup page if there is an error
51+
failureFlash : true // allow flash messages
52+
}));
53+
54+
// facebook -------------------------------
55+
56+
// send to facebook to do the authentication
57+
app.get('/auth/facebook', passport.authenticate('facebook', { scope : 'email' }));
58+
59+
// handle the callback after facebook has authenticated the user
60+
app.get('/auth/facebook/callback',
61+
passport.authenticate('facebook', {
62+
successRedirect : '/profile',
63+
failureRedirect : '/'
64+
}));
65+
66+
// twitter --------------------------------
67+
68+
// send to twitter to do the authentication
69+
app.get('/auth/twitter', passport.authenticate('twitter', { scope : 'email' }));
70+
71+
// handle the callback after twitter has authenticated the user
72+
app.get('/auth/twitter/callback',
73+
passport.authenticate('twitter', {
74+
successRedirect : '/profile',
75+
failureRedirect : '/'
76+
}));
77+
78+
79+
// google ---------------------------------
80+
81+
// send to google to do the authentication
82+
app.get('/auth/google', passport.authenticate('google', { scope : ['profile', 'email'] }));
83+
84+
// the callback after google has authenticated the user
85+
app.get('/auth/google/callback',
86+
passport.authenticate('google', {
87+
successRedirect : '/profile',
88+
failureRedirect : '/'
89+
}));
9090

9191
// =============================================================================
9292
// AUTHORIZE (ALREADY LOGGED IN / CONNECTING OTHER SOCIAL ACCOUNT) =============
9393
// =============================================================================
9494

95-
// locally --------------------------------
96-
app.get('/connect/local', function(req, res) {
97-
res.render('connect-local.ejs', { message: req.flash('loginMessage') });
98-
});
99-
app.post('/connect/local', passport.authenticate('local-signup', {
100-
successRedirect : '/profile', // redirect to the secure profile section
101-
failureRedirect : '/connect/local', // redirect back to the signup page if there is an error
102-
failureFlash : true // allow flash messages
103-
}));
95+
// locally --------------------------------
96+
app.get('/connect/local', function(req, res) {
97+
res.render('connect-local.ejs', { message: req.flash('loginMessage') });
98+
});
99+
app.post('/connect/local', passport.authenticate('local-signup', {
100+
successRedirect : '/profile', // redirect to the secure profile section
101+
failureRedirect : '/connect/local', // redirect back to the signup page if there is an error
102+
failureFlash : true // allow flash messages
103+
}));
104104

105-
// facebook -------------------------------
105+
// facebook -------------------------------
106106

107-
// send to facebook to do the authentication
108-
app.get('/connect/facebook', passport.authorize('facebook', { scope : 'email' }));
107+
// send to facebook to do the authentication
108+
app.get('/connect/facebook', passport.authorize('facebook', { scope : 'email' }));
109109

110-
// handle the callback after facebook has authorized the user
111-
app.get('/connect/facebook/callback',
112-
passport.authorize('facebook', {
113-
successRedirect : '/profile',
114-
failureRedirect : '/'
115-
}));
110+
// handle the callback after facebook has authorized the user
111+
app.get('/connect/facebook/callback',
112+
passport.authorize('facebook', {
113+
successRedirect : '/profile',
114+
failureRedirect : '/'
115+
}));
116116

117-
// twitter --------------------------------
117+
// twitter --------------------------------
118118

119-
// send to twitter to do the authentication
120-
app.get('/connect/twitter', passport.authorize('twitter', { scope : 'email' }));
119+
// send to twitter to do the authentication
120+
app.get('/connect/twitter', passport.authorize('twitter', { scope : 'email' }));
121121

122-
// handle the callback after twitter has authorized the user
123-
app.get('/connect/twitter/callback',
124-
passport.authorize('twitter', {
125-
successRedirect : '/profile',
126-
failureRedirect : '/'
127-
}));
122+
// handle the callback after twitter has authorized the user
123+
app.get('/connect/twitter/callback',
124+
passport.authorize('twitter', {
125+
successRedirect : '/profile',
126+
failureRedirect : '/'
127+
}));
128128

129129

130-
// google ---------------------------------
130+
// google ---------------------------------
131131

132-
// send to google to do the authentication
133-
app.get('/connect/google', passport.authorize('google', { scope : ['profile', 'email'] }));
132+
// send to google to do the authentication
133+
app.get('/connect/google', passport.authorize('google', { scope : ['profile', 'email'] }));
134134

135-
// the callback after google has authorized the user
136-
app.get('/connect/google/callback',
137-
passport.authorize('google', {
138-
successRedirect : '/profile',
139-
failureRedirect : '/'
140-
}));
135+
// the callback after google has authorized the user
136+
app.get('/connect/google/callback',
137+
passport.authorize('google', {
138+
successRedirect : '/profile',
139+
failureRedirect : '/'
140+
}));
141141

142142
// =============================================================================
143143
// UNLINK ACCOUNTS =============================================================
@@ -146,50 +146,50 @@ module.exports = function(app, passport) {
146146
// for local account, remove email and password
147147
// user account will stay active in case they want to reconnect in the future
148148

149-
// local -----------------------------------
150-
app.get('/unlink/local', isLoggedIn, function(req, res) {
151-
var user = req.user;
152-
user.local.email = undefined;
153-
user.local.password = undefined;
154-
user.save(function(err) {
155-
res.redirect('/profile');
156-
});
157-
});
158-
159-
// facebook -------------------------------
160-
app.get('/unlink/facebook', isLoggedIn, function(req, res) {
161-
var user = req.user;
162-
user.facebook.token = undefined;
163-
user.save(function(err) {
164-
res.redirect('/profile');
165-
});
166-
});
167-
168-
// twitter --------------------------------
169-
app.get('/unlink/twitter', isLoggedIn, function(req, res) {
170-
var user = req.user;
171-
user.twitter.token = undefined;
172-
user.save(function(err) {
173-
res.redirect('/profile');
174-
});
175-
});
176-
177-
// google ---------------------------------
178-
app.get('/unlink/google', isLoggedIn, function(req, res) {
179-
var user = req.user;
180-
user.google.token = undefined;
181-
user.save(function(err) {
182-
res.redirect('/profile');
183-
});
184-
});
149+
// local -----------------------------------
150+
app.get('/unlink/local', isLoggedIn, function(req, res) {
151+
var user = req.user;
152+
user.local.email = undefined;
153+
user.local.password = undefined;
154+
user.save(function(err) {
155+
res.redirect('/profile');
156+
});
157+
});
158+
159+
// facebook -------------------------------
160+
app.get('/unlink/facebook', isLoggedIn, function(req, res) {
161+
var user = req.user;
162+
user.facebook.token = undefined;
163+
user.save(function(err) {
164+
res.redirect('/profile');
165+
});
166+
});
167+
168+
// twitter --------------------------------
169+
app.get('/unlink/twitter', isLoggedIn, function(req, res) {
170+
var user = req.user;
171+
user.twitter.token = undefined;
172+
user.save(function(err) {
173+
res.redirect('/profile');
174+
});
175+
});
176+
177+
// google ---------------------------------
178+
app.get('/unlink/google', isLoggedIn, function(req, res) {
179+
var user = req.user;
180+
user.google.token = undefined;
181+
user.save(function(err) {
182+
res.redirect('/profile');
183+
});
184+
});
185185

186186

187187
};
188188

189189
// route middleware to ensure user is logged in
190190
function isLoggedIn(req, res, next) {
191-
if (req.isAuthenticated())
192-
return next();
191+
if (req.isAuthenticated())
192+
return next();
193193

194-
res.redirect('/');
194+
res.redirect('/');
195195
}

0 commit comments

Comments
 (0)