summaryrefslogtreecommitdiffstats
path: root/web/react
diff options
context:
space:
mode:
authorReed Garmsen <rgarmsen2295@gmail.com>2015-10-05 14:18:05 -0700
committerReed Garmsen <rgarmsen2295@gmail.com>2015-10-05 14:29:20 -0700
commit817fa66ac4db9522488c1760417ca57cb1b56c20 (patch)
tree69089398d6bd3bccd78b5637758c1daff676c3fc /web/react
parentaad9529f31d9ec6966aaffab1083b6108031a505 (diff)
downloadchat-817fa66ac4db9522488c1760417ca57cb1b56c20.tar.gz
chat-817fa66ac4db9522488c1760417ca57cb1b56c20.tar.bz2
chat-817fa66ac4db9522488c1760417ca57cb1b56c20.zip
Added better verification when a user changes his or her email
Diffstat (limited to 'web/react')
-rw-r--r--web/react/components/user_settings/user_settings_general.jsx37
1 files changed, 32 insertions, 5 deletions
diff --git a/web/react/components/user_settings/user_settings_general.jsx b/web/react/components/user_settings/user_settings_general.jsx
index bd7ed12db..d2f1117d5 100644
--- a/web/react/components/user_settings/user_settings_general.jsx
+++ b/web/react/components/user_settings/user_settings_general.jsx
@@ -28,6 +28,7 @@ export default class UserSettingsGeneralTab extends React.Component {
this.updateLastName = this.updateLastName.bind(this);
this.updateNickname = this.updateNickname.bind(this);
this.updateEmail = this.updateEmail.bind(this);
+ this.updateConfirmEmail = this.updateConfirmEmail.bind(this);
this.updatePicture = this.updatePicture.bind(this);
this.updateSection = this.updateSection.bind(this);
@@ -97,6 +98,7 @@ export default class UserSettingsGeneralTab extends React.Component {
var user = UserStore.getCurrentUser();
var email = this.state.email.trim().toLowerCase();
+ var confirmEmail = this.state.confirmEmail.trim().toLowerCase();
if (user.email === email) {
return;
@@ -107,12 +109,17 @@ export default class UserSettingsGeneralTab extends React.Component {
return;
}
+ if (email !== confirmEmail) {
+ this.setState({emailError: 'The new emails you entered do not match'});
+ return;
+ }
+
user.email = email;
- if (!this.state.emailEnabled || !this.state.emailVerificationEnabled) {
- this.submitUser(user, {emailChangeInProgress: false});
- } else {
+ if (this.state.emailEnabled && this.state.emailVerificationEnabled) {
this.submitUser(user, {emailChangeInProgress: true});
+ } else {
+ this.submitUser(user, {emailChangeInProgress: false});
}
}
submitUser(user, newState) {
@@ -191,6 +198,9 @@ export default class UserSettingsGeneralTab extends React.Component {
updateEmail(e) {
this.setState({email: e.target.value});
}
+ updateConfirmEmail(e) {
+ this.setState({confirmEmail: e.target.value});
+ }
updatePicture(e) {
if (e.target.files && e.target.files[0]) {
this.setState({picture: e.target.files[0]});
@@ -202,7 +212,8 @@ export default class UserSettingsGeneralTab extends React.Component {
}
}
updateSection(section) {
- this.setState(assign({}, this.setupInitialState(this.props), {clientError: '', serverError: '', emailError: ''}));
+ const emailChangeInProgress = this.state.emailChangeInProgress;
+ this.setState(assign({}, this.setupInitialState(this.props), {emailChangeInProgress: emailChangeInProgress, clientError: '', serverError: '', emailError: ''}));
this.submitActive = false;
this.props.updateSection(section);
}
@@ -226,7 +237,7 @@ export default class UserSettingsGeneralTab extends React.Component {
var emailVerificationEnabled = global.window.config.RequireEmailVerification === 'true';
return {username: user.username, firstName: user.first_name, lastName: user.last_name, nickname: user.nickname,
- email: user.email, picture: null, loadingPicture: false, emailEnabled: emailEnabled,
+ email: user.email, confirmEmail: '', picture: null, loadingPicture: false, emailEnabled: emailEnabled,
emailVerificationEnabled: emailVerificationEnabled, emailChangeInProgress: false};
}
render() {
@@ -477,6 +488,22 @@ export default class UserSettingsGeneralTab extends React.Component {
/>
</div>
</div>
+ </div>
+ );
+
+ inputs.push(
+ <div key='confirmEmailSetting'>
+ <div className='form-group'>
+ <label className='col-sm-5 control-label'>{'Confirm Email'}</label>
+ <div className='col-sm-7'>
+ <input
+ className='form-control'
+ type='text'
+ onChange={this.updateConfirmEmail}
+ value={this.state.confirmEmail}
+ />
+ </div>
+ </div>
{helpText}
</div>
);