Merge branch 'JahlomP-master'
* JahlomP-master: Renamed Referer to Referrer Code refactoring of redirect to last URL Removed TODO section referrer redirect Added a redirection to referrer page
This commit is contained in:
@ -1009,10 +1009,6 @@ Add this to `package.json`, after *name* and *version*. This is necessary becaus
|
|||||||
- **Note:** *You will be prompted for the password you created earlier*
|
- **Note:** *You will be prompted for the password you created earlier*
|
||||||
- On **Deployments** tab of your Windows Azure Web Site, you will see the deployment history
|
- On **Deployments** tab of your Windows Azure Web Site, you will see the deployment history
|
||||||
|
|
||||||
TODO
|
|
||||||
----
|
|
||||||
- Pages that require login, should automatically redirect to last attempted URL on successful sign-in.
|
|
||||||
|
|
||||||
Contributing
|
Contributing
|
||||||
------------
|
------------
|
||||||
If something is unclear, confusing, or needs to be refactored, please let me know. Pull requests are always welcome, but due to the opinionated nature of this project, I cannot accept every pull request. Please open an issue before submitting a pull request. This project uses [Airbnb JavaScript Style Guide](https://github.com/airbnb/javascript) with a few minor exceptions. If you are submitting a pull request that involves Jade templates, please make sure you are using *spaces*, not tabs.
|
If something is unclear, confusing, or needs to be refactored, please let me know. Pull requests are always welcome, but due to the opinionated nature of this project, I cannot accept every pull request. Please open an issue before submitting a pull request. This project uses [Airbnb JavaScript Style Guide](https://github.com/airbnb/javascript) with a few minor exceptions. If you are submitting a pull request that involves Jade templates, please make sure you are using *spaces*, not tabs.
|
||||||
|
@ -9,6 +9,7 @@ var User = require('../models/User');
|
|||||||
|
|
||||||
exports.getLogin = function(req, res) {
|
exports.getLogin = function(req, res) {
|
||||||
if (req.user) return res.redirect('/');
|
if (req.user) return res.redirect('/');
|
||||||
|
req.session.lastUrl = req.header('Referrer');
|
||||||
res.render('account/login', {
|
res.render('account/login', {
|
||||||
title: 'Login'
|
title: 'Login'
|
||||||
});
|
});
|
||||||
@ -34,16 +35,14 @@ exports.postLogin = function(req, res, next) {
|
|||||||
|
|
||||||
passport.authenticate('local', function(err, user, info) {
|
passport.authenticate('local', function(err, user, info) {
|
||||||
if (err) return next(err);
|
if (err) return next(err);
|
||||||
|
|
||||||
if (!user) {
|
if (!user) {
|
||||||
req.flash('errors', { msg: info.message });
|
req.flash('errors', { msg: info.message });
|
||||||
return res.redirect('/login');
|
return res.redirect('/login');
|
||||||
}
|
}
|
||||||
|
|
||||||
req.logIn(user, function(err) {
|
req.logIn(user, function(err) {
|
||||||
if (err) return next(err);
|
if (err) return next(err);
|
||||||
req.flash('success', { msg: 'Success! You are logged in.' });
|
req.flash('success', { msg: 'Success! You are logged in.' });
|
||||||
return res.redirect('/');
|
res.redirect(req.session.lastUrl || '/');
|
||||||
});
|
});
|
||||||
})(req, res, next);
|
})(req, res, next);
|
||||||
};
|
};
|
||||||
|
Reference in New Issue
Block a user