From aad9529f31d9ec6966aaffab1083b6108031a505 Mon Sep 17 00:00:00 2001 From: Reed Garmsen Date: Fri, 2 Oct 2015 16:30:21 -0700 Subject: Initial cosmetic changes to the process of verifying a changed email --- .../user_settings/user_settings_general.jsx | 46 +++++++++++++++++++--- 1 file changed, 41 insertions(+), 5 deletions(-) (limited to 'web/react/components/user_settings/user_settings_general.jsx') diff --git a/web/react/components/user_settings/user_settings_general.jsx b/web/react/components/user_settings/user_settings_general.jsx index c1d4c4ab5..bd7ed12db 100644 --- a/web/react/components/user_settings/user_settings_general.jsx +++ b/web/react/components/user_settings/user_settings_general.jsx @@ -2,6 +2,7 @@ // See License.txt for license information. var UserStore = require('../../stores/user_store.jsx'); +var ErrorStore = require('../../stores/error_store.jsx'); var SettingItemMin = require('../setting_item_min.jsx'); var SettingItemMax = require('../setting_item_max.jsx'); var SettingPicture = require('../setting_picture.jsx'); @@ -108,13 +109,26 @@ export default class UserSettingsGeneralTab extends React.Component { user.email = email; - this.submitUser(user); + if (!this.state.emailEnabled || !this.state.emailVerificationEnabled) { + this.submitUser(user, {emailChangeInProgress: false}); + } else { + this.submitUser(user, {emailChangeInProgress: true}); + } } - submitUser(user) { + submitUser(user, newState) { client.updateUser(user, function updateSuccess() { this.updateSection(''); AsyncClient.getMe(); + + if (newState) { + if (newState.emailChangeInProgress) { + ErrorStore.storeLastError({message: 'Check your email at ' + user.email + ' to verify the address.'}); + ErrorStore.emitChange(); + } + + this.setState(newState); + } }.bind(this), function updateFailure(err) { var state = this.setupInitialState(this.props); @@ -209,8 +223,11 @@ export default class UserSettingsGeneralTab extends React.Component { setupInitialState(props) { var user = props.user; var emailEnabled = global.window.config.SendEmailNotifications === 'true'; + 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, picture: null, loadingPicture: false, emailEnabled: emailEnabled, + emailVerificationEnabled: emailVerificationEnabled, emailChangeInProgress: false}; } render() { var user = this.props.user; @@ -434,10 +451,17 @@ export default class UserSettingsGeneralTab extends React.Component { } var emailSection; if (this.props.activeSection === 'email') { - let helpText =
Email is used for notifications, and requires verification if changed.
; + let helpText = 'Email is used for notifications, and requires verification if changed.'; if (!this.state.emailEnabled) { helpText =
{'Email has been disabled by your system administrator. No notification emails will be sent until it is enabled.'}
; + } else if (!this.state.emailVerificationEnabled) { + helpText = 'Email is used for notifications.'; + } else if (this.state.emailChangeInProgress) { + const newEmail = UserStore.getCurrentUser().email; + if (newEmail) { + helpText = 'A verification email was sent to ' + newEmail + '.'; + } } inputs.push( @@ -471,10 +495,22 @@ export default class UserSettingsGeneralTab extends React.Component { /> ); } else { + let describe = ''; + if (this.state.emailChangeInProgress) { + const newEmail = UserStore.getCurrentUser().email; + if (newEmail) { + describe = 'New Address: ' + newEmail + '\nCheck your email to verify the above address.'; + } else { + describe = 'Check your email to verify your new address'; + } + } else { + describe = UserStore.getCurrentUser().email; + } + emailSection = ( Date: Mon, 5 Oct 2015 14:18:05 -0700 Subject: Added better verification when a user changes his or her email --- .../user_settings/user_settings_general.jsx | 37 +++++++++++++++++++--- 1 file changed, 32 insertions(+), 5 deletions(-) (limited to 'web/react/components/user_settings/user_settings_general.jsx') 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 { /> + + ); + + inputs.push( +
+
+ +
+ +
+
{helpText}
); -- cgit v1.2.3-1-g7c22 From c84fe62ca199485dccefc37e00ca2bef45d47c6d Mon Sep 17 00:00:00 2001 From: Reed Garmsen Date: Tue, 6 Oct 2015 08:58:31 -0700 Subject: Added new email to email change notification --- .../user_settings/user_settings_general.jsx | 32 ++++++++-------------- 1 file changed, 12 insertions(+), 20 deletions(-) (limited to 'web/react/components/user_settings/user_settings_general.jsx') diff --git a/web/react/components/user_settings/user_settings_general.jsx b/web/react/components/user_settings/user_settings_general.jsx index d2f1117d5..c6c508ad7 100644 --- a/web/react/components/user_settings/user_settings_general.jsx +++ b/web/react/components/user_settings/user_settings_general.jsx @@ -115,26 +115,19 @@ export default class UserSettingsGeneralTab extends React.Component { } user.email = email; - - if (this.state.emailEnabled && this.state.emailVerificationEnabled) { - this.submitUser(user, {emailChangeInProgress: true}); - } else { - this.submitUser(user, {emailChangeInProgress: false}); - } + this.submitUser(user); } - submitUser(user, newState) { + submitUser(user) { client.updateUser(user, function updateSuccess() { this.updateSection(''); AsyncClient.getMe(); + const verificationEnabled = global.window.config.SendEmailNotifications === 'true' && global.window.config.RequireEmailVerification === 'true'; - if (newState) { - if (newState.emailChangeInProgress) { - ErrorStore.storeLastError({message: 'Check your email at ' + user.email + ' to verify the address.'}); - ErrorStore.emitChange(); - } - - this.setState(newState); + if (verificationEnabled) { + ErrorStore.storeLastError({message: 'Check your email at ' + user.email + ' to verify the address.'}); + ErrorStore.emitChange(); + this.setState({emailChangeInProgress: true}); } }.bind(this), function updateFailure(err) { @@ -233,12 +226,9 @@ export default class UserSettingsGeneralTab extends React.Component { } setupInitialState(props) { var user = props.user; - var emailEnabled = global.window.config.SendEmailNotifications === 'true'; - 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, confirmEmail: '', picture: null, loadingPicture: false, emailEnabled: emailEnabled, - emailVerificationEnabled: emailVerificationEnabled, emailChangeInProgress: false}; + email: user.email, confirmEmail: '', picture: null, loadingPicture: false, emailChangeInProgress: false}; } render() { var user = this.props.user; @@ -462,11 +452,13 @@ export default class UserSettingsGeneralTab extends React.Component { } var emailSection; if (this.props.activeSection === 'email') { + const emailEnabled = global.window.config.SendEmailNotifications === 'true'; + const emailVerificationEnabled = global.window.config.RequireEmailVerification === 'true'; let helpText = 'Email is used for notifications, and requires verification if changed.'; - if (!this.state.emailEnabled) { + if (!emailEnabled) { helpText =
{'Email has been disabled by your system administrator. No notification emails will be sent until it is enabled.'}
; - } else if (!this.state.emailVerificationEnabled) { + } else if (!emailVerificationEnabled) { helpText = 'Email is used for notifications.'; } else if (this.state.emailChangeInProgress) { const newEmail = UserStore.getCurrentUser().email; -- cgit v1.2.3-1-g7c22