Remove sign up page and update button styles

This commit is contained in:
Mrugesh Mohapatra
2016-12-16 00:32:07 +05:30
committed by Berkeley Martinez
parent e941545d2e
commit 239313cb0b
5 changed files with 43 additions and 74 deletions

View File

@ -266,7 +266,8 @@ h1, h2, h3, h4, h5, h6, p, li {
}
.btn-social {
width: 250px;
width: 100%;
max-width: 260px;
margin: auto;
}

View File

@ -323,6 +323,38 @@ module.exports = function(User) {
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) {
if (!isEmail(info.email)) {
console.error(createEmailError());

View File

@ -25,6 +25,7 @@ import {
import supportedLanguages from '../../common/utils/supported-languages';
import { getChallengeInfo, cachedMap } from '../utils/map';
const isSignUpDisabled = !!process.env.DISABLE_SIGNUP;
const debug = debugFactory('fcc:boot:user');
const sendNonUserToMap = ifNoUserRedirectTo('/map');
const certIds = {
@ -170,14 +171,13 @@ module.exports = function(app) {
router.get('/logout', function(req, res) {
res.redirect(301, '/signout');
});
router.get('/signup', getEmailSignup);
router.get('/signup', getSignin);
router.get('/signin', getSignin);
router.get('/signout', signout);
router.get('/forgot', getForgot);
api.post('/forgot', postForgot);
router.get('/reset-password', getReset);
api.post('/reset-password', postReset);
router.get('/email-signup', getEmailSignup);
router.get('/email-signin', getEmailSignin);
router.get('/deprecated-signin', getDepSignin);
router.get('/update-email', getUpdateEmail);
@ -438,12 +438,16 @@ module.exports = function(app) {
if (req.user) {
return res.redirect('/');
}
if (isSignUpDisabled) {
return res.render('account/beta', {
title: 'New sign ups are disabled'
});
}
return res.render('account/email-signin', {
title: 'Sign in to freeCodeCamp using your Email Address'
});
}
const isSignUpDisabled = !!process.env.DISABLE_SIGNUP;
function getEmailSignup(req, res) {
if (req.user) {
return res.redirect('/');

View File

@ -10,7 +10,7 @@ block content
#flash-content
.row
.text-center
h2 Sign in with an Email here:
h2 Sign in or Sign Up with an Email here:
.button-spacer
.col-sm-6.col-sm-offset-3
form(method='POST', action='/passwordless-auth')

View File

@ -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();
}
});
});
});