diff options
author | Reed Garmsen <rgarmsen2295@gmail.com> | 2015-10-06 08:58:31 -0700 |
---|---|---|
committer | Reed Garmsen <rgarmsen2295@gmail.com> | 2015-10-06 09:15:56 -0700 |
commit | c84fe62ca199485dccefc37e00ca2bef45d47c6d (patch) | |
tree | 8e60c594e261e391b6a1e0bc36361a7393caa23f /web/react/components/user_settings/user_settings_general.jsx | |
parent | f85dc7f575a9aad45d7914279300a22e9a6fae8a (diff) | |
download | chat-c84fe62ca199485dccefc37e00ca2bef45d47c6d.tar.gz chat-c84fe62ca199485dccefc37e00ca2bef45d47c6d.tar.bz2 chat-c84fe62ca199485dccefc37e00ca2bef45d47c6d.zip |
Added new email to email change notification
Diffstat (limited to 'web/react/components/user_settings/user_settings_general.jsx')
-rw-r--r-- | web/react/components/user_settings/user_settings_general.jsx | 32 |
1 files changed, 12 insertions, 20 deletions
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 = <div className='setting-list__hint text-danger'>{'Email has been disabled by your system administrator. No notification emails will be sent until it is enabled.'}</div>; - } else if (!this.state.emailVerificationEnabled) { + } else if (!emailVerificationEnabled) { helpText = 'Email is used for notifications.'; } else if (this.state.emailChangeInProgress) { const newEmail = UserStore.getCurrentUser().email; |