Added 3 second delay to account creation to sidestep a bug
This commit is contained in:
+13
-7
@@ -69,7 +69,7 @@ const signupRequest = (connection) => (req, res) => {
|
|||||||
//build the verification email
|
//build the verification email
|
||||||
let addr = `http://${process.env.WEB_ADDRESS}/verifyrequest?email=${fields.email}&verify=${rand}`;
|
let addr = `http://${process.env.WEB_ADDRESS}/verifyrequest?email=${fields.email}&verify=${rand}`;
|
||||||
let msg = 'Hello! Please visit the following address to verify your account: ';
|
let msg = 'Hello! Please visit the following address to verify your account: ';
|
||||||
let msgHtml = `<html><body><p>${msg}<a href='${addr}'>${addr}</a></p></body></html>`;
|
// let msgHtml = `<html><body><p>${msg}<a href='${addr}'>${addr}</a></p></body></html>`;
|
||||||
|
|
||||||
//BUGFIX: is gmail being cruel?
|
//BUGFIX: is gmail being cruel?
|
||||||
let sentinel = false;
|
let sentinel = false;
|
||||||
@@ -80,7 +80,7 @@ const signupRequest = (connection) => (req, res) => {
|
|||||||
to: fields.email,
|
to: fields.email,
|
||||||
subject: 'Email Verification',
|
subject: 'Email Verification',
|
||||||
text: msg + addr,
|
text: msg + addr,
|
||||||
html: msgHtml
|
// html: msgHtml
|
||||||
}, (err, reply) => {
|
}, (err, reply) => {
|
||||||
if (err) { //final check
|
if (err) { //final check
|
||||||
let msg = log('Something went wrong (did you use a valid email?)', err);
|
let msg = log('Something went wrong (did you use a valid email?)', err);
|
||||||
@@ -90,7 +90,7 @@ const signupRequest = (connection) => (req, res) => {
|
|||||||
res.end();
|
res.end();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
let msg = log('Verification email sent!', fields.email);
|
let msg = log('Verification email sent!', fields.email, fields.username, rand);
|
||||||
|
|
||||||
if (!sentinel) {
|
if (!sentinel) {
|
||||||
res.status(200).json({ msg: msg });
|
res.status(200).json({ msg: msg });
|
||||||
@@ -114,7 +114,6 @@ const verifyRequest = (connection) => (req, res) => {
|
|||||||
|
|
||||||
//correct number of results
|
//correct number of results
|
||||||
if (results.length !== 1) {
|
if (results.length !== 1) {
|
||||||
console.log(req.query.email);
|
|
||||||
res.status(400).write(log('That account does not exist or this link has already been used.', req.query.email, req.query.verify));
|
res.status(400).write(log('That account does not exist or this link has already been used.', req.query.email, req.query.verify));
|
||||||
res.end();
|
res.end();
|
||||||
return;
|
return;
|
||||||
@@ -127,8 +126,12 @@ console.log(req.query.email);
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//BUGFIX: a delay to prevent the fail message appearing to the end user
|
||||||
|
setTimeout(() => {
|
||||||
|
log('Trying to create account', req.query.email);
|
||||||
|
|
||||||
//move the data from signups to accounts
|
//move the data from signups to accounts
|
||||||
let query = 'INSERT INTO accounts (email, username, salt, hash) VALUES (?, ?, ?, ?);';
|
let query = 'INSERT IGNORE INTO accounts (email, username, salt, hash) VALUES (?, ?, ?, ?);';
|
||||||
connection.query(query, [results[0].email, results[0].username, results[0].salt, results[0].hash], (err) => {
|
connection.query(query, [results[0].email, results[0].username, results[0].salt, results[0].hash], (err) => {
|
||||||
if (err) throw err;
|
if (err) throw err;
|
||||||
|
|
||||||
@@ -137,12 +140,15 @@ console.log(req.query.email);
|
|||||||
connection.query(query, [results[0].email], (err) => {
|
connection.query(query, [results[0].email], (err) => {
|
||||||
if (err) throw err;
|
if (err) throw err;
|
||||||
|
|
||||||
|
log('Account created', req.query.email);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}, 3000); //3 second delay on account creation
|
||||||
|
|
||||||
//TODO: prettier verification page
|
//TODO: prettier verification page
|
||||||
res.status(200).write(log('Verification succeeded!', req.query.email));
|
res.status(200).write(log('Verification succeeded!', req.query.email));
|
||||||
res.end();
|
res.end();
|
||||||
});
|
});
|
||||||
});
|
|
||||||
});
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const loginRequest = (connection) => (req, res) => {
|
const loginRequest = (connection) => (req, res) => {
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ export const STORE_RECRUITS = 'STORE_RECRUITS';
|
|||||||
export const STORE_SOLDIERS = 'STORE_SOLDIERS';
|
export const STORE_SOLDIERS = 'STORE_SOLDIERS';
|
||||||
export const STORE_SPIES = 'STORE_SPIES';
|
export const STORE_SPIES = 'STORE_SPIES';
|
||||||
export const STORE_SCIENTISTS = 'STORE_SCIENTISTS';
|
export const STORE_SCIENTISTS = 'STORE_SCIENTISTS';
|
||||||
|
export const CLEAR_PROFILE = 'CLEAR_PROFILE';
|
||||||
|
|
||||||
export const storeProfile = (username, gold, recruits, soldiers, spies, scientists) => {
|
export const storeProfile = (username, gold, recruits, soldiers, spies, scientists) => {
|
||||||
return {
|
return {
|
||||||
@@ -59,3 +60,9 @@ export const storeScientists = (scientists) => {
|
|||||||
scientists: scientists
|
scientists: scientists
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const clearProfile = () => {
|
||||||
|
return {
|
||||||
|
type: CLEAR_PROFILE
|
||||||
|
};
|
||||||
|
}
|
||||||
@@ -4,7 +4,7 @@ import { connect } from 'react-redux';
|
|||||||
import queryString from 'query-string';
|
import queryString from 'query-string';
|
||||||
|
|
||||||
//actions
|
//actions
|
||||||
import { storeProfile } from '../../actions/profile.js';
|
import { storeProfile, clearProfile } from '../../actions/profile.js';
|
||||||
|
|
||||||
//panels
|
//panels
|
||||||
import CommonLinks from '../panels/common_links.jsx';
|
import CommonLinks from '../panels/common_links.jsx';
|
||||||
@@ -22,6 +22,10 @@ class Profile extends React.Component {
|
|||||||
this.sendRequest('/profilerequest', {username: this.state.params.username ? this.state.params.username : this.props.account.username});
|
this.sendRequest('/profilerequest', {username: this.state.params.username ? this.state.params.username : this.props.account.username});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
componentWillUnmount() {
|
||||||
|
this.props.clearProfile();
|
||||||
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
let warningStyle = {
|
let warningStyle = {
|
||||||
display: this.state.warning.length > 0 ? 'flex' : 'none'
|
display: this.state.warning.length > 0 ? 'flex' : 'none'
|
||||||
@@ -343,7 +347,8 @@ const mapStoreToProps = (store) => {
|
|||||||
|
|
||||||
const mapDispatchToProps = (dispatch) => {
|
const mapDispatchToProps = (dispatch) => {
|
||||||
return {
|
return {
|
||||||
storeProfile: (username, gold, recruits, soldiers, spies, scientists) => dispatch(storeProfile(username, gold, recruits, soldiers, spies, scientists))
|
storeProfile: (username, gold, recruits, soldiers, spies, scientists) => dispatch(storeProfile(username, gold, recruits, soldiers, spies, scientists)),
|
||||||
|
clearProfile: () => dispatch(clearProfile())
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -5,7 +5,8 @@ import {
|
|||||||
STORE_RECRUITS,
|
STORE_RECRUITS,
|
||||||
STORE_SOLDIERS,
|
STORE_SOLDIERS,
|
||||||
STORE_SPIES,
|
STORE_SPIES,
|
||||||
STORE_SCIENTISTS
|
STORE_SCIENTISTS,
|
||||||
|
CLEAR_PROFILE
|
||||||
} from '../actions/profile.js';
|
} from '../actions/profile.js';
|
||||||
|
|
||||||
const initialStore = {
|
const initialStore = {
|
||||||
@@ -53,6 +54,10 @@ export const profileReducer = (store = initialStore, action) => {
|
|||||||
case STORE_SCIENTISTS:
|
case STORE_SCIENTISTS:
|
||||||
newStore.scientists = action.scientists;
|
newStore.scientists = action.scientists;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case CLEAR_PROFILE:
|
||||||
|
newStore = JSON.parse(JSON.stringify(initialStore));
|
||||||
|
break;
|
||||||
};
|
};
|
||||||
|
|
||||||
return newStore;
|
return newStore;
|
||||||
|
|||||||
Reference in New Issue
Block a user