diff --git a/api/templates/email_change_body.html b/api/templates/email_change_body.html
index 0ec4ace2a5..7addb6f35d 100644
--- a/api/templates/email_change_body.html
+++ b/api/templates/email_change_body.html
@@ -18,7 +18,7 @@
You updated your email
- You updated your email for {{.Props.TeamDisplayName}} on {{ .Props.TeamURL }} If this change wasn't initiated by you, please reply to this email and let us know.
+ You email address for {{.Props.TeamDisplayName}} has been changed. If you did not make this change, please contact the system administrator.
|
@@ -51,4 +51,3 @@
{{end}}
-
diff --git a/api/templates/email_change_subject.html b/api/templates/email_change_subject.html
index 5690b148a4..962ae868ea 100644
--- a/api/templates/email_change_subject.html
+++ b/api/templates/email_change_subject.html
@@ -1 +1 @@
-{{define "email_change_subject"}}You updated your email for {{.Props.TeamDisplayName}} on {{ .Props.Domain }}{{end}}
+{{define "email_change_subject"}}[{{.ClientProps.SiteName}}] Your email address has changed for {{.Props.TeamDisplayName}}{{end}}
diff --git a/api/templates/email_change_verify_body.html b/api/templates/email_change_verify_body.html
new file mode 100644
index 0000000000..296a3d9680
--- /dev/null
+++ b/api/templates/email_change_verify_body.html
@@ -0,0 +1,56 @@
+{{define "verify_new_email_body"}}
+
+
+
+
+
+
+
+
+
+
+
+ |
+
+
+
+
+
+
+ You updated your email
+ To finish updating your email address for {{.Props.TeamDisplayName}}, please click the link below to confirm this is the right address.
+
+ Verify Email
+
+ |
+
+
+
+ Any questions at all, mail us any time: {{.ClientProps.FeedbackEmail}}.
+ Best wishes,
+ The {{.ClientProps.SiteName}} Team
+ |
+
+
+ |
+
+
+ |
+
+
+
+
+ (c) 2015 SpinPunch, Inc. 855 El Camino Real, 13A-168, Palo Alto, CA, 94301.
+ If you no longer wish to receive these emails, click on the following link: Unsubscribe
+
+ |
+
+
+ |
+
+
+ |
+
+
+
+{{end}}
diff --git a/api/templates/email_change_verify_subject.html b/api/templates/email_change_verify_subject.html
new file mode 100644
index 0000000000..f1cebd710a
--- /dev/null
+++ b/api/templates/email_change_verify_subject.html
@@ -0,0 +1 @@
+{{define "verify_new_email_subject"}}[{{.ClientProps.SiteName}}] Verify new email address for {{.Props.TeamDisplayName}}{{end}}
diff --git a/utils/config.go b/utils/config.go
index 44c4c43aff..0a2697e6ca 100644
--- a/utils/config.go
+++ b/utils/config.go
@@ -189,6 +189,7 @@ func getClientProperties(c *model.Config) map[string]string {
props["SendEmailNotifications"] = strconv.FormatBool(c.EmailSettings.SendEmailNotifications)
props["EnableSignUpWithEmail"] = strconv.FormatBool(c.EmailSettings.EnableSignUpWithEmail)
+ props["RequireEmailVerification"] = strconv.FormatBool(c.EmailSettings.RequireEmailVerification)
props["FeedbackEmail"] = c.EmailSettings.FeedbackEmail
props["EnableSignUpWithGitLab"] = strconv.FormatBool(c.GitLabSettings.Enable)
diff --git a/web/react/components/user_settings/user_settings_general.jsx b/web/react/components/user_settings/user_settings_general.jsx
index c1d4c4ab52..bd7ed12dbd 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 = (