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:
committed by
Quincy Larson
parent
17410c722b
commit
26bf5afccd
@ -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', {
|
||||
|
@ -39,6 +39,7 @@
|
||||
},
|
||||
"routes:before": {
|
||||
"express-flash": {},
|
||||
"./middlewares/coming-from-com": {},
|
||||
"helmet#xssFilter": {},
|
||||
"helmet#noSniff": {},
|
||||
"helmet#frameguard": {},
|
||||
|
11
server/middlewares/coming-from-com.js
Normal file
11
server/middlewares/coming-from-com.js
Normal 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();
|
||||
};
|
||||
};
|
16
server/views/account/signin-com.jade
Normal file
16
server/views/account/signin-com.jade
Normal 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.
|
Reference in New Issue
Block a user