fix(views): Adjust routes and views
This commit is contained in:
@ -29,23 +29,25 @@ module.exports = function enableAuthentication(app) {
|
|||||||
const api = app.loopback.Router();
|
const api = app.loopback.Router();
|
||||||
const { AuthToken, User } = app.models;
|
const { AuthToken, User } = app.models;
|
||||||
|
|
||||||
router.get('/signup', (req, res) => res.redirect(301, '/login'));
|
|
||||||
router.get('/email-signin', (req, res) => res.redirect(301, '/login'));
|
router.get('/email-signin', (req, res) => res.redirect(301, '/login'));
|
||||||
router.get('/signin', (req, res) => res.redirect(301, '/login'));
|
router.get('/signin', (req, res) => res.redirect(301, '/login'));
|
||||||
router.get('/signout', (req, res) => res.redirect(301, '/logout'));
|
router.get('/signout', (req, res) => res.redirect(301, '/logout'));
|
||||||
|
router.get('/signup', (req, res) => res.redirect(301, '/deprecated-signup'));
|
||||||
|
|
||||||
function getEmailSignin(req, res) {
|
function getLegacySignUp(req, res) {
|
||||||
if (isSignUpDisabled) {
|
if (isSignUpDisabled) {
|
||||||
return res.render('account/beta', {
|
return res.render('account/beta', {
|
||||||
title: 'New sign ups are disabled'
|
title: 'New sign ups are disabled'
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
return res.render('account/email-signin', {
|
return res.render('account/deprecated-signup', {
|
||||||
title: 'Sign in to freeCodeCamp using your Email Address'
|
title: 'Sign in to freeCodeCamp using your Email Address'
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
router.get('/deprecated-signup', ifUserRedirect, getLegacySignUp);
|
||||||
router.get('/login', ifUserRedirect, getEmailSignin);
|
router.get('/login',
|
||||||
|
ifUserRedirect,
|
||||||
|
(req, res) => res.redirect(301, '/auth/auth0'));
|
||||||
|
|
||||||
router.get('/logout', (req, res) => {
|
router.get('/logout', (req, res) => {
|
||||||
req.logout();
|
req.logout();
|
||||||
|
@ -172,6 +172,7 @@ export default {
|
|||||||
clientID: process.env.AUTH0_CLIENT_ID,
|
clientID: process.env.AUTH0_CLIENT_ID,
|
||||||
clientSecret: process.env.AUTH0_CLIENT_SECRET,
|
clientSecret: process.env.AUTH0_CLIENT_SECRET,
|
||||||
domain: process.env.AUTH0_DOMAIN,
|
domain: process.env.AUTH0_DOMAIN,
|
||||||
|
cookieDomain: 'freeCodeCamp.org',
|
||||||
callbackURL: '/auth/auth0/callback',
|
callbackURL: '/auth/auth0/callback',
|
||||||
authPath: '/auth/auth0',
|
authPath: '/auth/auth0',
|
||||||
callbackPath: '/auth/auth0/callback',
|
callbackPath: '/auth/auth0/callback',
|
||||||
|
@ -1,7 +1,10 @@
|
|||||||
extends ../layout
|
extends ../layout
|
||||||
block content
|
block content
|
||||||
|
.container
|
||||||
|
.col-xs-12
|
||||||
|
.row
|
||||||
.text-center
|
.text-center
|
||||||
h2 If you originally signed up using one of these methods, you can sign in and add your email address to your account:
|
h3 Sign in with one of these options if you used them as your original sign up methods :
|
||||||
br
|
br
|
||||||
a.btn.btn-lg.btn-block.btn-social.btn-github(href='/auth/github')
|
a.btn.btn-lg.btn-block.btn-social.btn-github(href='/auth/github')
|
||||||
i.fa.fa-github
|
i.fa.fa-github
|
||||||
@ -19,6 +22,11 @@ block content
|
|||||||
i.fa.fa-twitter
|
i.fa.fa-twitter
|
||||||
| Sign in with Twitter
|
| Sign in with Twitter
|
||||||
br
|
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
|
p
|
||||||
a(href="/signin") Or click here to go back.
|
a(href="/signin") Or click here to go back.
|
||||||
|
|
||||||
|
15
server/views/account/deprecated-signup.jade
Normal file
15
server/views/account/deprecated-signup.jade
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
extends ../layout
|
||||||
|
block content
|
||||||
|
.container
|
||||||
|
.col-xs-12
|
||||||
|
.row
|
||||||
|
.text-center
|
||||||
|
h2 Sign up (or sign in with your existing account)
|
||||||
|
br
|
||||||
|
a.btn.btn-lg.btn-primary(href='/auth/auth0')
|
||||||
|
| Get a link on your email
|
||||||
|
.row
|
||||||
|
.text-center
|
||||||
|
br
|
||||||
|
a(href="/deprecated-signin")
|
||||||
|
| Continute with old sign in methods
|
@ -1,140 +0,0 @@
|
|||||||
extends ../layout
|
|
||||||
block content
|
|
||||||
.container
|
|
||||||
.col-xs-12
|
|
||||||
.row
|
|
||||||
.col-sm-6.col-sm-offset-3.flashMessage.negative-30
|
|
||||||
#flash-board.alert.fade.in(style='display: none;')
|
|
||||||
button.close(type='button', data-dismiss='alert')
|
|
||||||
span.ion-close-circled#flash-close
|
|
||||||
#flash-content
|
|
||||||
.row
|
|
||||||
.text-center
|
|
||||||
h2 Sign up (or sign in with your existing account)
|
|
||||||
.button-spacer
|
|
||||||
.col-sm-6.col-sm-offset-3
|
|
||||||
form(method='POST', action='/passwordless-auth')
|
|
||||||
input(type='hidden', name='_csrf', value=_csrf)
|
|
||||||
.form-group
|
|
||||||
input.input-lg.form-control(type='email', name='email', id='email', placeholder='Enter your email address', autofocus=true, required, oninvalid="this.setCustomValidity('Enter your email address')", oninput="setCustomValidity('')")
|
|
||||||
.button-spacer
|
|
||||||
div.checkbox
|
|
||||||
label
|
|
||||||
input(type='checkbox', name='quincy-emails', checked=false)
|
|
||||||
span.cr
|
|
||||||
i.cr-icon.fa.fa-check
|
|
||||||
| I want weekly emails from Quincy, freeCodeCamp.org's founder.
|
|
||||||
div.checkbox
|
|
||||||
label
|
|
||||||
input#terms-privacy(type='checkbox', name='terms-privacy', checked=false)
|
|
||||||
span.cr
|
|
||||||
i.cr-icon.fa.fa-check
|
|
||||||
| I accept the
|
|
||||||
a(href="/terms" target="_blank") Terms of Service
|
|
||||||
| and
|
|
||||||
a(href="/privacy" target="_blank") Privacy Policy
|
|
||||||
| (required).
|
|
||||||
.button-spacer
|
|
||||||
button#magic-btn.btn.btn-primary.btn-lg.btn-block(type='submit')
|
|
||||||
| Get a sign in link
|
|
||||||
.row
|
|
||||||
.col-sm-6.col-sm-offset-3
|
|
||||||
br
|
|
||||||
p.text-center
|
|
||||||
br
|
|
||||||
br
|
|
||||||
a(href="/deprecated-signin") Try old sign in methods
|
|
||||||
|
|
||||||
script.
|
|
||||||
$(document).ready(function() {
|
|
||||||
function disableMagicButton (isDisabled, isLaunched) {
|
|
||||||
if (isDisabled) {
|
|
||||||
$('#magic-btn')
|
|
||||||
.prop('disabled', true)
|
|
||||||
.html('<span style="color:#E0E0E0;"><i class="fa fa-circle-o-notch fa-spin fa-fw"></i>OK - we\'re sending you an email. Open it and click sign in link.</span>');
|
|
||||||
} else {
|
|
||||||
$('#magic-btn')
|
|
||||||
.prop('disabled', true)
|
|
||||||
.html('<span style="color:#E0E0E0;">If you didn\'t get the email, check your spam folder, or reload the page to try again.</span>');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function disableMagicButtonForAgreement (isLaunched) {
|
|
||||||
if(isLaunched) {
|
|
||||||
$('#magic-btn')
|
|
||||||
.prop('disabled', true)
|
|
||||||
.html('<span style="color:#E0E0E0;">Get a sign in link</span>');
|
|
||||||
return;
|
|
||||||
} else {
|
|
||||||
$('#magic-btn')
|
|
||||||
.prop('disabled', false)
|
|
||||||
.html('<span>Get a sign in link</span>');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
disableMagicButtonForAgreement(true);
|
|
||||||
|
|
||||||
$('#terms-privacy').click(function(){
|
|
||||||
if(this.checked) {
|
|
||||||
disableMagicButtonForAgreement(false);
|
|
||||||
} else {
|
|
||||||
disableMagicButtonForAgreement(true);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
$('form').submit(function(event){
|
|
||||||
event.preventDefault();
|
|
||||||
$('#flash-board').hide();
|
|
||||||
disableMagicButton(true);
|
|
||||||
var $form = $(event.target);
|
|
||||||
$.ajax({
|
|
||||||
type : 'POST',
|
|
||||||
url : $form.attr('action'),
|
|
||||||
data : $form.serialize(),
|
|
||||||
dataType : 'json',
|
|
||||||
encode : true,
|
|
||||||
xhrFields : { withCredentials: true }
|
|
||||||
})
|
|
||||||
.fail(error => {
|
|
||||||
if (error.responseText){
|
|
||||||
var data = JSON.parse(error.responseText);
|
|
||||||
if(data.error && data.error.message) {
|
|
||||||
$('#flash-content').html(data.error.message);
|
|
||||||
$('#flash-board')
|
|
||||||
.removeClass('alert-success')
|
|
||||||
.addClass('alert-info')
|
|
||||||
.slideDown(400)
|
|
||||||
.delay(800)
|
|
||||||
.fadeIn();
|
|
||||||
disableMagicButton(false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.done(data => {
|
|
||||||
if(data && data.message) {
|
|
||||||
var alertType = 'alert-';
|
|
||||||
switch (data.type) {
|
|
||||||
case 'errors': {
|
|
||||||
alertType += 'danger';
|
|
||||||
break
|
|
||||||
}
|
|
||||||
case 'success': {
|
|
||||||
alertType += 'success';
|
|
||||||
break
|
|
||||||
}
|
|
||||||
default: {
|
|
||||||
alertType += 'info';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$('#flash-content').html(data.message);
|
|
||||||
$('#flash-board')
|
|
||||||
.removeClass('alert-info alert-success alert-danger')
|
|
||||||
.addClass(alertType)
|
|
||||||
.slideDown(400)
|
|
||||||
.delay(800)
|
|
||||||
.fadeIn();
|
|
||||||
disableMagicButton(false);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
Reference in New Issue
Block a user