Remove sign up page and update button styles
This commit is contained in:
committed by
Berkeley Martinez
parent
e941545d2e
commit
239313cb0b
@ -266,7 +266,8 @@ h1, h2, h3, h4, h5, h6, p, li {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.btn-social {
|
.btn-social {
|
||||||
width: 250px;
|
width: 100%;
|
||||||
|
max-width: 260px;
|
||||||
margin: auto;
|
margin: auto;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -323,6 +323,38 @@ module.exports = function(User) {
|
|||||||
return ctx.res.redirect(redirect);
|
return ctx.res.redirect(redirect);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
User.beforeRemote('create', function({ req, res }, _, next) {
|
||||||
|
req.body.username = 'fcc' + uuid.v4().slice(0, 8);
|
||||||
|
if (!req.body.email) {
|
||||||
|
return next();
|
||||||
|
}
|
||||||
|
if (!isEmail(req.body.email)) {
|
||||||
|
return next(new Error('Email format is not valid'));
|
||||||
|
}
|
||||||
|
return User.doesExist(null, req.body.email)
|
||||||
|
.then(exists => {
|
||||||
|
if (!exists) {
|
||||||
|
return next();
|
||||||
|
}
|
||||||
|
|
||||||
|
req.flash('error', {
|
||||||
|
msg: dedent`
|
||||||
|
The ${req.body.email} email address is already associated with an account.
|
||||||
|
Try signing in with it here instead.
|
||||||
|
`
|
||||||
|
});
|
||||||
|
|
||||||
|
return res.redirect('/email-signin');
|
||||||
|
})
|
||||||
|
.catch(err => {
|
||||||
|
console.error(err);
|
||||||
|
req.flash('error', {
|
||||||
|
msg: 'Oops, something went wrong, please try again later'
|
||||||
|
});
|
||||||
|
return res.redirect('/email-signin');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
User.on('resetPasswordRequest', function(info) {
|
User.on('resetPasswordRequest', function(info) {
|
||||||
if (!isEmail(info.email)) {
|
if (!isEmail(info.email)) {
|
||||||
console.error(createEmailError());
|
console.error(createEmailError());
|
||||||
|
@ -25,6 +25,7 @@ import {
|
|||||||
import supportedLanguages from '../../common/utils/supported-languages';
|
import supportedLanguages from '../../common/utils/supported-languages';
|
||||||
import { getChallengeInfo, cachedMap } from '../utils/map';
|
import { getChallengeInfo, cachedMap } from '../utils/map';
|
||||||
|
|
||||||
|
const isSignUpDisabled = !!process.env.DISABLE_SIGNUP;
|
||||||
const debug = debugFactory('fcc:boot:user');
|
const debug = debugFactory('fcc:boot:user');
|
||||||
const sendNonUserToMap = ifNoUserRedirectTo('/map');
|
const sendNonUserToMap = ifNoUserRedirectTo('/map');
|
||||||
const certIds = {
|
const certIds = {
|
||||||
@ -170,14 +171,13 @@ module.exports = function(app) {
|
|||||||
router.get('/logout', function(req, res) {
|
router.get('/logout', function(req, res) {
|
||||||
res.redirect(301, '/signout');
|
res.redirect(301, '/signout');
|
||||||
});
|
});
|
||||||
router.get('/signup', getEmailSignup);
|
router.get('/signup', getSignin);
|
||||||
router.get('/signin', getSignin);
|
router.get('/signin', getSignin);
|
||||||
router.get('/signout', signout);
|
router.get('/signout', signout);
|
||||||
router.get('/forgot', getForgot);
|
router.get('/forgot', getForgot);
|
||||||
api.post('/forgot', postForgot);
|
api.post('/forgot', postForgot);
|
||||||
router.get('/reset-password', getReset);
|
router.get('/reset-password', getReset);
|
||||||
api.post('/reset-password', postReset);
|
api.post('/reset-password', postReset);
|
||||||
router.get('/email-signup', getEmailSignup);
|
|
||||||
router.get('/email-signin', getEmailSignin);
|
router.get('/email-signin', getEmailSignin);
|
||||||
router.get('/deprecated-signin', getDepSignin);
|
router.get('/deprecated-signin', getDepSignin);
|
||||||
router.get('/update-email', getUpdateEmail);
|
router.get('/update-email', getUpdateEmail);
|
||||||
@ -438,12 +438,16 @@ module.exports = function(app) {
|
|||||||
if (req.user) {
|
if (req.user) {
|
||||||
return res.redirect('/');
|
return res.redirect('/');
|
||||||
}
|
}
|
||||||
|
if (isSignUpDisabled) {
|
||||||
|
return res.render('account/beta', {
|
||||||
|
title: 'New sign ups are disabled'
|
||||||
|
});
|
||||||
|
}
|
||||||
return res.render('account/email-signin', {
|
return res.render('account/email-signin', {
|
||||||
title: 'Sign in to freeCodeCamp using your Email Address'
|
title: 'Sign in to freeCodeCamp using your Email Address'
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
const isSignUpDisabled = !!process.env.DISABLE_SIGNUP;
|
|
||||||
function getEmailSignup(req, res) {
|
function getEmailSignup(req, res) {
|
||||||
if (req.user) {
|
if (req.user) {
|
||||||
return res.redirect('/');
|
return res.redirect('/');
|
||||||
|
@ -10,7 +10,7 @@ block content
|
|||||||
#flash-content
|
#flash-content
|
||||||
.row
|
.row
|
||||||
.text-center
|
.text-center
|
||||||
h2 Sign in with an Email here:
|
h2 Sign in or Sign Up with an Email here:
|
||||||
.button-spacer
|
.button-spacer
|
||||||
.col-sm-6.col-sm-offset-3
|
.col-sm-6.col-sm-offset-3
|
||||||
form(method='POST', action='/passwordless-auth')
|
form(method='POST', action='/passwordless-auth')
|
||||||
|
@ -1,68 +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 Are you new to Free Code Camp?
|
|
||||||
br
|
|
||||||
.button-spacer
|
|
||||||
| Sign up with an Email here:
|
|
||||||
.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='Email', autofocus=true)
|
|
||||||
.button-spacer
|
|
||||||
button.btn.btn-primary.btn-lg.btn-block(type='submit')
|
|
||||||
span.fa.fa-envelope
|
|
||||||
| Get a magic link to sign up.
|
|
||||||
.row
|
|
||||||
.col-sm-6.col-sm-offset-3
|
|
||||||
br
|
|
||||||
p.text-center
|
|
||||||
a(href="/signin") Click here if you already have an account and want to sign in.
|
|
||||||
|
|
||||||
script.
|
|
||||||
$(document).ready(function() {
|
|
||||||
$('form').submit(function(event){
|
|
||||||
event.preventDefault();
|
|
||||||
$('#flash-board').hide();
|
|
||||||
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')
|
|
||||||
.fadeIn();
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.done(data =>{
|
|
||||||
if(data && data.message){
|
|
||||||
$('#flash-content').html(data.message);
|
|
||||||
$('#flash-board')
|
|
||||||
.removeClass('alert-info')
|
|
||||||
.addClass('alert-success')
|
|
||||||
.fadeIn();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
Reference in New Issue
Block a user