diff --git a/server/component-passport.js b/server/component-passport.js index 71790ba89a..86c9d2a709 100644 --- a/server/component-passport.js +++ b/server/component-passport.js @@ -4,6 +4,7 @@ import { PassportConfigurator } from import passportProviders from './passport-providers'; import url from 'url'; import jwt from 'jsonwebtoken'; +import dedent from 'dedent'; const passportOptions = { emailOptional: true, @@ -133,11 +134,24 @@ export default function setupPassport(app) { delete redirect.search; const { accessToken } = userInfo; + const { provider } = config; if (accessToken && accessToken.id) { - req.flash( - 'success', - 'Success! You have signed in to your account. Happy Coding!' - ); + if (provider === 'auth0') { + req.flash( + 'success', + dedent` + Success! You have signed in to your account. Happy Coding! + ` + ); + } else if (user.email) { + req.flash( + 'info', + dedent` + We are moving away from social authentication for privacy reasons. Next time + we recommend using your email address: ${user.email} to sign in instead. + ` + ); + } const cookieConfig = { signed: !!req.signedCookies, maxAge: accessToken.ttl, diff --git a/server/passport-providers.js b/server/passport-providers.js index bab270396b..9c3bc144ee 100644 --- a/server/passport-providers.js +++ b/server/passport-providers.js @@ -23,6 +23,7 @@ export default { authPath: '/auth/facebook', callbackURL: '/auth/facebook/callback', callbackPath: '/auth/facebook/callback', + useCustomCallback: true, successRedirect: successRedirect, failureRedirect: failureRedirect, scope: ['email'], @@ -51,6 +52,7 @@ export default { authPath: '/auth/google', callbackURL: '/auth/google/callback', callbackPath: '/auth/google/callback', + useCustomCallback: true, successRedirect: successRedirect, failureRedirect: failureRedirect, scope: ['email', 'profile'], @@ -78,6 +80,7 @@ export default { authPath: '/auth/twitter', callbackURL: '/auth/twitter/callback', callbackPath: '/auth/twitter/callback', + useCustomCallback: true, successRedirect: successRedirect, failureRedirect: failureRedirect, consumerKey: process.env.TWITTER_KEY, @@ -105,6 +108,7 @@ export default { authPath: '/auth/linkedin', callbackURL: '/auth/linkedin/callback', callbackPath: '/auth/linkedin/callback', + useCustomCallback: true, successRedirect: successRedirect, failureRedirect: failureRedirect, clientID: process.env.LINKEDIN_ID, @@ -142,6 +146,7 @@ export default { authPath: '/auth/github', callbackURL: '/auth/github/callback', callbackPath: '/auth/github/callback', + useCustomCallback: true, successRedirect: successRedirect, failureRedirect: failureRedirect, clientID: process.env.GITHUB_ID, diff --git a/server/views/account/deprecated-signin.jade b/server/views/account/deprecated-signin.jade index 9d51f4f018..e247515287 100644 --- a/server/views/account/deprecated-signin.jade +++ b/server/views/account/deprecated-signin.jade @@ -4,7 +4,8 @@ block content .col-xs-12 .row .text-center - h3 Sign in with one of these options if you used them as your original sign up methods : + 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.fa.fa-github @@ -21,43 +22,3 @@ block content a.btn.btn-lg.btn-block.btn-social.btn-twitter(href='/auth/twitter') i.fa.fa-twitter | Sign in with Twitter - br - h3 - | We are unable to create new accounts using these methods - h4 If you haven't updated your email with us, you should do that as soon as possible, - | after you login here, to avoid losing access to your account. - br - p - a(href="/signin") Or click here to go back. - - script. - $(document).ready(function() { - var method = localStorage.getItem('lastSigninMethodDeprecated'), - btnSelector = 'a.btn.btn-lg.btn-block.btn-social'; - if (method) { - try { - var obj = JSON.parse(method); - } catch(e) { - console.error('Invalid sign in object stored', method); - return; - } - $.each($(btnSelector), function(i, item) { - if ( - $(item).attr('href') === obj.methodLink && - $(item).hasClass(obj.methodClass) - ) { - $(item).addClass('active'); - $(item).attr('title', 'This is your last signin method'); - return false; - } - }); - } - - $(btnSelector).click(function() { - var obj = {}; - $(this).removeClass('active'); - obj.methodClass = $(this).attr('class').split(' ').pop(); - obj.methodLink = $(this).attr('href'); - localStorage.setItem('lastSigninMethodDeprecated', JSON.stringify(obj)); - }); - });