From e60fb1dfd77609c21689dc5d3d0ba001229fbed4 Mon Sep 17 00:00:00 2001 From: Christopher Speller Date: Tue, 13 Oct 2015 11:31:57 -0400 Subject: [PATCH 1/4] Fixing user settings dialog so it desn't ask you to check your email unless you changed it --- .../user_settings/user_settings_general.jsx | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/web/react/components/user_settings/user_settings_general.jsx b/web/react/components/user_settings/user_settings_general.jsx index c23c619487..ac3a2e37b5 100644 --- a/web/react/components/user_settings/user_settings_general.jsx +++ b/web/react/components/user_settings/user_settings_general.jsx @@ -59,7 +59,7 @@ export default class UserSettingsGeneralTab extends React.Component { user.username = username; - this.submitUser(user); + this.submitUser(user, false); } submitNickname(e) { e.preventDefault(); @@ -74,7 +74,7 @@ export default class UserSettingsGeneralTab extends React.Component { user.nickname = nickname; - this.submitUser(user); + this.submitUser(user, false); } submitName(e) { e.preventDefault(); @@ -91,7 +91,7 @@ export default class UserSettingsGeneralTab extends React.Component { user.first_name = firstName; user.last_name = lastName; - this.submitUser(user); + this.submitUser(user, false); } submitEmail(e) { e.preventDefault(); @@ -115,22 +115,22 @@ export default class UserSettingsGeneralTab extends React.Component { } user.email = email; - this.submitUser(user); + this.submitUser(user, true); } - submitUser(user) { + submitUser(user, emailUpdated) { client.updateUser(user, - function updateSuccess() { + () => { this.updateSection(''); AsyncClient.getMe(); - const verificationEnabled = global.window.config.SendEmailNotifications === 'true' && global.window.config.RequireEmailVerification === 'true'; + const verificationEnabled = global.window.config.SendEmailNotifications === 'true' && global.window.config.RequireEmailVerification === 'true' && emailUpdated; 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) { + }, + (err) => { var state = this.setupInitialState(this.props); if (err.message) { state.serverError = err.message; @@ -138,7 +138,7 @@ export default class UserSettingsGeneralTab extends React.Component { state.serverError = err; } this.setState(state); - }.bind(this) + } ); } submitPicture(e) { From 0187e702eae59fd5435ea2b061d1087a3882eb09 Mon Sep 17 00:00:00 2001 From: =Corey Hulen Date: Tue, 13 Oct 2015 09:47:31 -0700 Subject: [PATCH 2/4] PLT-602 combining welcome and verify email --- api/templates/welcome_body.html | 11 +++++++++++ api/user.go | 13 ++++++++----- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/api/templates/welcome_body.html b/api/templates/welcome_body.html index 94b597cbb3..b7cb3704d1 100644 --- a/api/templates/welcome_body.html +++ b/api/templates/welcome_body.html @@ -15,6 +15,17 @@ + {{if .Props.VerifyUrl }} + + + + {{end}}
+

You've been invited

+

Please verify your email address by clicking below.

+

+ Verify Email +

+

You can sign-in to your new team from the web address:

diff --git a/api/user.go b/api/user.go index faf828cf99..146ede0154 100644 --- a/api/user.go +++ b/api/user.go @@ -198,13 +198,12 @@ func CreateUser(c *Context, team *model.Team, user *model.User) *model.User { l4g.Error("Encountered an issue joining default channels user_id=%s, team_id=%s, err=%v", ruser.Id, ruser.TeamId, err) } - fireAndForgetWelcomeEmail(ruser.Email, team.DisplayName, c.GetSiteURL(), c.GetTeamURLFromTeam(team)) + fireAndForgetWelcomeEmail(result.Data.(*model.User).Id, ruser.Email, team.Name, team.DisplayName, c.GetSiteURL(), c.GetTeamURLFromTeam(team), user.EmailVerified) + if user.EmailVerified { if cresult := <-Srv.Store.User().VerifyEmail(ruser.Id); cresult.Err != nil { l4g.Error("Failed to set email verified err=%v", cresult.Err) } - } else { - FireAndForgetVerifyEmail(result.Data.(*model.User).Id, ruser.Email, team.Name, team.DisplayName, c.GetSiteURL(), c.GetTeamURLFromTeam(team)) } ruser.Sanitize(map[string]bool{}) @@ -218,7 +217,7 @@ func CreateUser(c *Context, team *model.Team, user *model.User) *model.User { } } -func fireAndForgetWelcomeEmail(email, teamDisplayName, siteURL, teamURL string) { +func fireAndForgetWelcomeEmail(userId, email, teamName, teamDisplayName, siteURL, teamURL string, verified bool) { go func() { subjectPage := NewServerTemplatePage("welcome_subject") @@ -227,10 +226,14 @@ func fireAndForgetWelcomeEmail(email, teamDisplayName, siteURL, teamURL string) bodyPage.Props["SiteURL"] = siteURL bodyPage.Props["TeamURL"] = teamURL + if !verified { + link := fmt.Sprintf("%s/verify_email?uid=%s&hid=%s&teamname=%s&email=%s", siteURL, userId, model.HashPassword(userId), teamName, email) + bodyPage.Props["VerifyUrl"] = link + } + if err := utils.SendMail(email, subjectPage.Render(), bodyPage.Render()); err != nil { l4g.Error("Failed to send welcome email successfully err=%v", err) } - }() } From ac0f8f6bcf9eb65b2541d537ef8960f0b5d3f0ff Mon Sep 17 00:00:00 2001 From: JoramWilander Date: Tue, 13 Oct 2015 18:01:11 -0400 Subject: [PATCH 3/4] Fix webhook name not overriding in LHS and update webhook help text. --- web/react/components/rhs_root_post.jsx | 45 ++++++++++++++++--- .../user_settings/manage_incoming_hooks.jsx | 3 +- 2 files changed, 40 insertions(+), 8 deletions(-) diff --git a/web/react/components/rhs_root_post.jsx b/web/react/components/rhs_root_post.jsx index c44844f347..442d3483ef 100644 --- a/web/react/components/rhs_root_post.jsx +++ b/web/react/components/rhs_root_post.jsx @@ -117,20 +117,51 @@ export default class RhsRootPost extends React.Component { ); } + let userProfile = ; + let botIndicator; + + if (post.props && post.props.from_webhook) { + if (post.props.override_username && global.window.config.EnablePostUsernameOverride === 'true') { + userProfile = ( + + ); + } + + botIndicator =
  • {'BOT'}
  • ; + } + + let src = '/api/v1/users/' + post.user_id + '/image?time=' + timestamp; + if (post.props && post.props.from_webhook && global.window.config.EnablePostIconOverride === 'true') { + if (post.props.override_icon_url) { + src = post.props.override_icon_url; + } + } + + const profilePic = ( +
    + +
    + ); + return (
    {channelName}
    - + {profilePic}
      -
    • +
    • {userProfile}
    • + {botIndicator}