feat(server/middlewares): Show signin to com users (#15569)

* feat(server/middlewares): Show signing to com users

When a signed in user is redirected from the com to the org (with the ref=com in the query) they will be
redirected to the signin page with a message letting them know why they are signed out

* feat(server): Redirected user see's special sigin page
This commit is contained in:
Berkeley Martinez
2017-06-29 22:16:15 -07:00
committed by Quincy Larson
parent 17410c722b
commit 26bf5afccd
4 changed files with 38 additions and 0 deletions

View File

@ -143,6 +143,7 @@ module.exports = function(app) {
res.redirect(301, '/signout');
});
router.get('/signin', getSignin);
router.get('/signin-com', getSigninCom);
router.get('/signout', signout);
router.get('/forgot', getForgot);
router.post('/forgot', postForgot);
@ -225,6 +226,15 @@ module.exports = function(app) {
});
}
function getSigninCom(req, res) {
if (req.user) {
return res.redirect('/');
}
return res.render('account/signin-com', {
title: 'Sign in to freeCodeCamp'
});
}
function signout(req, res) {
req.logout();
req.flash('success', {

View File

@ -39,6 +39,7 @@
},
"routes:before": {
"express-flash": {},
"./middlewares/coming-from-com": {},
"helmet#xssFilter": {},
"helmet#noSniff": {},
"helmet#frameguard": {},

View File

@ -0,0 +1,11 @@
export default () => {
return function comingFromCom(req, res, next) {
if (
!req.user &&
req.query.ref === 'com'
) {
return res.redirect('/signin-com');
}
return next();
};
};

View File

@ -0,0 +1,16 @@
extends ../layout
block content
.text-center
h2 Welcome to our new freecodecamp.ORG address.
h4 We sent you here from our old freecodecamp.COM address.
h4 Please sign in again to continue coding. Thanks!
.spacer
a.btn.btn-lg.btn-block.btn-social.btn-primary(href='/email-signin')
i.fa.fa-envelope
| Sign in with Email
a.btn.btn-lg.btn-block.btn-social.btn-github(href='/auth/github')
i.fa.fa-github
| Sign in with GitHub
.button-spacer
p
a(href="/deprecated-signin") Click here if you previously signed in using a different method.