From 38bcc2e250a367ca639235e890b266f6476b7434 Mon Sep 17 00:00:00 2001 From: Mrugesh Mohapatra Date: Thu, 28 Jun 2018 15:02:22 +0530 Subject: [PATCH] fix(auth): Remove deprecated views and routes --- server/boot/authentication.js | 17 ++++++----------- server/middlewares/csp.js | 3 ++- server/views/account/deprecated-signin.jade | 21 --------------------- server/views/account/deprecated-signup.jade | 20 -------------------- 4 files changed, 8 insertions(+), 53 deletions(-) delete mode 100644 server/views/account/deprecated-signin.jade delete mode 100644 server/views/account/deprecated-signup.jade diff --git a/server/boot/authentication.js b/server/boot/authentication.js index 2c874382e1..ecc6e352f4 100644 --- a/server/boot/authentication.js +++ b/server/boot/authentication.js @@ -21,7 +21,7 @@ if (isSignUpDisabled) { module.exports = function enableAuthentication(app) { // enable loopback access control authentication. see: - // loopback.io/doc/en/lb2/Authentication-authorization-and-permissions.html + // loopback.io/doc/en/lb2/Authentication-authorization-and-permissions.html app.enableAuth(); const ifUserRedirect = ifUserRedirectTo(); const ifNoUserRedirectHome = ifNoUserRedirectTo(homeURL); @@ -32,11 +32,14 @@ module.exports = function enableAuthentication(app) { router.get('/signup', (req, res) => res.redirect(301, '/signin')); router.get('/email-signin', (req, res) => res.redirect(301, '/signin')); router.get('/login', (req, res) => res.redirect(301, '/signin')); + router.get('/deprecated-signin', (req, res) => res.redirect(301, '/signin')); + router.get('/logout', (req, res) => res.redirect(301, '/signout')); router.get('/signin', - ifUserRedirect, - (req, res) => res.redirect(301, '/auth/auth0')); + ifUserRedirect, + (req, res) => res.redirect('/auth/auth0') + ); router.get( '/update-email', @@ -71,14 +74,6 @@ module.exports = function enableAuthentication(app) { }); }); - router.get( - '/deprecated-signin', - ifUserRedirect, - (req, res) => res.render('account/deprecated-signin', { - title: 'Sign in to freeCodeCamp using a Deprecated Login' - }) - ); - router.get( '/accept-privacy-terms', ifNoUserRedirectHome, diff --git a/server/middlewares/csp.js b/server/middlewares/csp.js index 9d34b967bd..146945ce78 100644 --- a/server/middlewares/csp.js +++ b/server/middlewares/csp.js @@ -3,7 +3,8 @@ import helmet from 'helmet'; let trusted = [ "'self'", 'https://search.freecodecamp.org', - 'https://*.algolianet.com' + 'https://*.algolianet.com', + 'https://' + process.env.AUTH0_DOMAIN ]; const host = process.env.HOST || 'localhost'; diff --git a/server/views/account/deprecated-signin.jade b/server/views/account/deprecated-signin.jade deleted file mode 100644 index 3400582cf4..0000000000 --- a/server/views/account/deprecated-signin.jade +++ /dev/null @@ -1,21 +0,0 @@ -extends ../layout -block content - .container - .col-xs-12 - .row - .text-center - br - h4 Select from the following deprecated sign in methods to access your account and add a valid email address to it. - br - a.btn.btn-lg.btn-block.btn-social.btn-github(href='/auth/github') - i.fab.fa-github - | Sign in with GitHub - a.btn.btn-lg.btn-block.btn-social.btn-facebook(href='/auth/facebook') - i.fab.fa-facebook - | Sign in with Facebook - a.btn.btn-lg.btn-block.btn-social.btn-google(href='/auth/google') - i.fab.fa-google - | Sign in with Google - a.btn.btn-lg.btn-block.btn-social.btn-twitter(href='/auth/twitter') - i.fab.fa-twitter - | Sign in with Twitter diff --git a/server/views/account/deprecated-signup.jade b/server/views/account/deprecated-signup.jade deleted file mode 100644 index b46594a565..0000000000 --- a/server/views/account/deprecated-signup.jade +++ /dev/null @@ -1,20 +0,0 @@ -extends ../layout -block content - .container - .col-xs-12 - .row - .text-center - h2 Sign up (or sign in with your existing account) - br - br - br - a.btn.btn-lg.btn-primary(href='/auth/auth0') - | Continue with your email - .row - .text-center - br - br - br - br - a(href="/deprecated-signin") - | Continute with an old sign in method, that you used previously.