Fixing links for signup from team invite link. Enter now advances signup_user_complete screen. Signin now link now redirects properly.

Этот коммит содержится в:
Christopher Speller
2015-07-29 16:17:20 -04:00
родитель 0f54233f66
Коммит 6222d2cb30
6 изменённых файлов: 27 добавлений и 26 удалений

Просмотреть файл

@@ -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) l4g.Error("Failed to set email verified err=%v", cresult.Err)
} }
} else { } 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{}) 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() { 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 := NewServerTemplatePage("verify_subject", teamURL)
subjectPage.Props["TeamDisplayName"] = teamDisplayName subjectPage.Props["TeamDisplayName"] = teamDisplayName
bodyPage := NewServerTemplatePage("verify_body", teamURL) bodyPage := NewServerTemplatePage("verify_body", teamURL)
bodyPage.Props["Nickname"] = name bodyPage.Props["Nickname"] = userNickname
bodyPage.Props["TeamDisplayName"] = teamDisplayName bodyPage.Props["TeamDisplayName"] = teamDisplayName
bodyPage.Props["VerifyUrl"] = link 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) l4g.Error("Failed to send verification email successfully err=%v", err)
} }
}() }()

Просмотреть файл

@@ -11,7 +11,7 @@ module.exports = React.createClass({
var resend = ""; var resend = "";
if (this.props.isVerified === "true") { if (this.props.isVerified === "true") {
title = config.SiteName + " Email Verified"; 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 { } else {
title = config.SiteName + " Email Not Verified"; title = config.SiteName + " Email Not Verified";
body = <p>Please verify your email address. Check your inbox for an email.</p>; body = <p>Please verify your email address. Check your inbox for an email.</p>;

Просмотреть файл

@@ -58,7 +58,7 @@ module.exports = React.createClass({
}.bind(this), }.bind(this),
function(err) { function(err) {
if (err.message == "Login failed because email address has not been verified") { 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 { } else {
this.state.server_error = err.message; this.state.server_error = err.message;
this.setState(this.state); this.setState(this.state);
@@ -107,7 +107,7 @@ module.exports = React.createClass({
<div className={ this.state.original_email == "" ? "margin--extra" : "hidden"} > <div className={ this.state.original_email == "" ? "margin--extra" : "hidden"} >
<h5><strong>What's your email address?</strong></h5> <h5><strong>What's your email address?</strong></h5>
<div className={ email_error ? "form-group has-error" : "form-group" }> <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 } { email_error }
</div> </div>
</div> </div>
@@ -123,6 +123,7 @@ module.exports = React.createClass({
return ( return (
<div> <div>
<form>
<img className="signup-team-logo" src="/static/images/logo.png" /> <img className="signup-team-logo" src="/static/images/logo.png" />
<h5 className="margin--less">Welcome to:</h5> <h5 className="margin--less">Welcome to:</h5>
<h2 className="signup-team__name">{ this.props.teamDisplayName }</h2> <h2 className="signup-team__name">{ this.props.teamDisplayName }</h2>
@@ -148,9 +149,10 @@ module.exports = React.createClass({
</div> </div>
</div> </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 } { 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> <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> </div>
); );
} }

Просмотреть файл

@@ -3,11 +3,9 @@
var EmailVerify = require('../components/email_verify.jsx'); 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( React.render(
<EmailVerify isVerified={is_verified} />, <EmailVerify isVerified={isVerified} teamURL={teamURL} userEmail={userEmail} />,
document.getElementById('verify') document.getElementById('verify')
); );
}; };

Просмотреть файл

@@ -9,7 +9,7 @@
</div> </div>
</div> </div>
<script> <script>
window.setup_verify_page('{{ .Props.IsVerified }}'); window.setupVerifyPage('{{.Props.IsVerified}}', '{{.Props.TeamURL}}', '{{.Props.UserEmail}}');
</script> </script>
</body> </body>
</html> </html>

Просмотреть файл

@@ -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) { func verifyEmail(c *api.Context, w http.ResponseWriter, r *http.Request) {
resend := r.URL.Query().Get("resend") resend := r.URL.Query().Get("resend")
name := r.URL.Query().Get("name") name := r.URL.Query().Get("teamname")
email := r.URL.Query().Get("email") email := r.URL.Query().Get("email")
hashedId := r.URL.Query().Get("hid") hashedId := r.URL.Query().Get("hid")
userId := r.URL.Query().Get("uid") userId := r.URL.Query().Get("uid")
if resend == "true" { var team *model.Team
teamId := ""
if result := <-api.Srv.Store.Team().GetByName(name); result.Err != nil { if result := <-api.Srv.Store.Team().GetByName(name); result.Err != nil {
c.Err = result.Err c.Err = result.Err
return return
} else { } else {
teamId = result.Data.(*model.Team).Id 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 c.Err = result.Err
return return
} else { } else {
user := result.Data.(*model.User) 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) http.Redirect(w, r, "/", http.StatusFound)
return return
} }
@@ -396,6 +395,8 @@ func verifyEmail(c *api.Context, w http.ResponseWriter, r *http.Request) {
page := NewHtmlTemplatePage("verify", "Email Verified") page := NewHtmlTemplatePage("verify", "Email Verified")
page.Props["IsVerified"] = isVerified page.Props["IsVerified"] = isVerified
page.Props["TeamURL"] = c.GetTeamURLFromTeam(team)
page.Props["UserEmail"] = email
page.Render(c, w) page.Render(c, w)
} }