summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--api/user.go10
-rw-r--r--web/react/components/email_verify.jsx2
-rw-r--r--web/react/components/signup_user_complete.jsx8
-rw-r--r--web/react/pages/verify.jsx6
-rw-r--r--web/templates/verify.html2
-rw-r--r--web/web.go25
6 files changed, 27 insertions, 26 deletions
diff --git a/api/user.go b/api/user.go
index e1d5e83dd..47464f5a1 100644
--- a/api/user.go
+++ b/api/user.go
@@ -193,7 +193,7 @@ func CreateUser(c *Context, team *model.Team, user *model.User) *model.User {
l4g.Error("Failed to set email verified err=%v", cresult.Err)
}
} else {
- FireAndForgetVerifyEmail(result.Data.(*model.User).Id, ruser.FirstName, ruser.Email, team.DisplayName, c.GetTeamURLFromTeam(team))
+ FireAndForgetVerifyEmail(result.Data.(*model.User).Id, ruser.Nickname, ruser.Email, team.Name, team.DisplayName, c.GetSiteURL(), c.GetTeamURLFromTeam(team))
}
ruser.Sanitize(map[string]bool{})
@@ -223,19 +223,19 @@ func fireAndForgetWelcomeEmail(name, email, teamDisplayName, link string) {
}()
}
-func FireAndForgetVerifyEmail(userId, name, email, teamDisplayName, teamURL string) {
+func FireAndForgetVerifyEmail(userId, userNickname, userEmail, teamName, teamDisplayName, siteURL, teamURL string) {
go func() {
- link := fmt.Sprintf("%s/verify_email?uid=%s&hid=%s", teamURL, userId, model.HashPassword(userId))
+ link := fmt.Sprintf("%s/verify_email?uid=%s&hid=%s&teamname=%s&email=%s", siteURL, userId, model.HashPassword(userId), teamName, userEmail)
subjectPage := NewServerTemplatePage("verify_subject", teamURL)
subjectPage.Props["TeamDisplayName"] = teamDisplayName
bodyPage := NewServerTemplatePage("verify_body", teamURL)
- bodyPage.Props["Nickname"] = name
+ bodyPage.Props["Nickname"] = userNickname
bodyPage.Props["TeamDisplayName"] = teamDisplayName
bodyPage.Props["VerifyUrl"] = link
- if err := utils.SendMail(email, subjectPage.Render(), bodyPage.Render()); err != nil {
+ if err := utils.SendMail(userEmail, subjectPage.Render(), bodyPage.Render()); err != nil {
l4g.Error("Failed to send verification email successfully err=%v", err)
}
}()
diff --git a/web/react/components/email_verify.jsx b/web/react/components/email_verify.jsx
index 168608274..678eb9928 100644
--- a/web/react/components/email_verify.jsx
+++ b/web/react/components/email_verify.jsx
@@ -11,7 +11,7 @@ module.exports = React.createClass({
var resend = "";
if (this.props.isVerified === "true") {
title = config.SiteName + " Email Verified";
- body = <p>Your email has been verified! Click <a href="/">here</a> to log in.</p>;
+ body = <p>Your email has been verified! Click <a href={this.props.teamURL + "?email=" + this.props.userEmail}>here</a> to log in.</p>;
} else {
title = config.SiteName + " Email Not Verified";
body = <p>Please verify your email address. Check your inbox for an email.</p>;
diff --git a/web/react/components/signup_user_complete.jsx b/web/react/components/signup_user_complete.jsx
index 670aab943..03808e821 100644
--- a/web/react/components/signup_user_complete.jsx
+++ b/web/react/components/signup_user_complete.jsx
@@ -58,7 +58,7 @@ module.exports = React.createClass({
}.bind(this),
function(err) {
if (err.message == "Login failed because email address has not been verified") {
- window.location.href = "/verify_email?email="+ encodeURIComponent(this.state.user.email) + "&domain=" + encodeURIComponent(this.props.teamName);
+ window.location.href = "/verify_email?email="+ encodeURIComponent(this.state.user.email) + "&teamname=" + encodeURIComponent(this.props.teamName);
} else {
this.state.server_error = err.message;
this.setState(this.state);
@@ -107,7 +107,7 @@ module.exports = React.createClass({
<div className={ this.state.original_email == "" ? "margin--extra" : "hidden"} >
<h5><strong>What's your email address?</strong></h5>
<div className={ email_error ? "form-group has-error" : "form-group" }>
- <input type="email" ref="email" className="form-control" defaultValue={ this.state.user.email } placeholder="" maxLength="128" />
+ <input type="email" ref="email" className="form-control" defaultValue={ this.state.user.email } placeholder="" maxLength="128" autoFocus={true} />
{ email_error }
</div>
</div>
@@ -123,6 +123,7 @@ module.exports = React.createClass({
return (
<div>
+ <form>
<img className="signup-team-logo" src="/static/images/logo.png" />
<h5 className="margin--less">Welcome to:</h5>
<h2 className="signup-team__name">{ this.props.teamDisplayName }</h2>
@@ -148,9 +149,10 @@ module.exports = React.createClass({
</div>
</div>
</div>
- <p className="margin--extra"><button onClick={this.handleSubmit} className="btn-primary btn">Create Account</button></p>
+ <p className="margin--extra"><button type='submit' onClick={this.handleSubmit} className="btn-primary btn">Create Account</button></p>
{ server_error }
<p>By creating an account and using Mattermost you are agreeing to our <a href={ config.TermsLink }>Terms of Service</a>. If you do not agree, you cannot use this service.</p>
+ </form>
</div>
);
}
diff --git a/web/react/pages/verify.jsx b/web/react/pages/verify.jsx
index 69850849f..96b556983 100644
--- a/web/react/pages/verify.jsx
+++ b/web/react/pages/verify.jsx
@@ -3,11 +3,9 @@
var EmailVerify = require('../components/email_verify.jsx');
-global.window.setup_verify_page = function(is_verified) {
-
+global.window.setupVerifyPage = function setupVerifyPage(isVerified, teamURL, userEmail) {
React.render(
- <EmailVerify isVerified={is_verified} />,
+ <EmailVerify isVerified={isVerified} teamURL={teamURL} userEmail={userEmail} />,
document.getElementById('verify')
);
-
};
diff --git a/web/templates/verify.html b/web/templates/verify.html
index a61964bb3..de839db68 100644
--- a/web/templates/verify.html
+++ b/web/templates/verify.html
@@ -9,7 +9,7 @@
</div>
</div>
<script>
- window.setup_verify_page('{{ .Props.IsVerified }}');
+ window.setupVerifyPage('{{.Props.IsVerified}}', '{{.Props.TeamURL}}', '{{.Props.UserEmail}}');
</script>
</body>
</html>
diff --git a/web/web.go b/web/web.go
index 68e2a5226..b51bf256a 100644
--- a/web/web.go
+++ b/web/web.go
@@ -352,27 +352,26 @@ func getChannel(c *api.Context, w http.ResponseWriter, r *http.Request) {
func verifyEmail(c *api.Context, w http.ResponseWriter, r *http.Request) {
resend := r.URL.Query().Get("resend")
- name := r.URL.Query().Get("name")
+ name := r.URL.Query().Get("teamname")
email := r.URL.Query().Get("email")
hashedId := r.URL.Query().Get("hid")
userId := r.URL.Query().Get("uid")
- if resend == "true" {
-
- teamId := ""
- if result := <-api.Srv.Store.Team().GetByName(name); result.Err != nil {
- c.Err = result.Err
- return
- } else {
- teamId = result.Data.(*model.Team).Id
- }
+ var team *model.Team
+ if result := <-api.Srv.Store.Team().GetByName(name); result.Err != nil {
+ c.Err = result.Err
+ return
+ } else {
+ team = result.Data.(*model.Team)
+ }
- if result := <-api.Srv.Store.User().GetByEmail(teamId, email); result.Err != nil {
+ if resend == "true" {
+ if result := <-api.Srv.Store.User().GetByEmail(team.Id, email); result.Err != nil {
c.Err = result.Err
return
} else {
user := result.Data.(*model.User)
- api.FireAndForgetVerifyEmail(user.Id, strings.Split(user.Nickname, " ")[0], user.Email, name, c.GetTeamURL())
+ api.FireAndForgetVerifyEmail(user.Id, user.Nickname, user.Email, team.Name, team.DisplayName, c.GetSiteURL(), c.GetTeamURLFromTeam(team))
http.Redirect(w, r, "/", http.StatusFound)
return
}
@@ -396,6 +395,8 @@ func verifyEmail(c *api.Context, w http.ResponseWriter, r *http.Request) {
page := NewHtmlTemplatePage("verify", "Email Verified")
page.Props["IsVerified"] = isVerified
+ page.Props["TeamURL"] = c.GetTeamURLFromTeam(team)
+ page.Props["UserEmail"] = email
page.Render(c, w)
}