Fixes mm-1415 adding email bypass flag

This commit is contained in:
=Corey Hulen
2015-07-12 23:36:52 -08:00
parent 27cab0f507
commit 252d0f3924
7 changed files with 29 additions and 28 deletions

View File

@@ -68,7 +68,7 @@ func signupTeam(c *Context, w http.ResponseWriter, r *http.Request) {
return
}
if utils.Cfg.ServiceSettings.Mode == utils.MODE_DEV {
if utils.Cfg.ServiceSettings.Mode == utils.MODE_DEV || utils.Cfg.EmailSettings.ByPassEmail {
m["follow_link"] = bodyPage.Props["Link"]
}

View File

@@ -293,7 +293,7 @@ func login(c *Context, w http.ResponseWriter, r *http.Request) {
return
}
if !user.EmailVerified {
if !user.EmailVerified && !utils.Cfg.EmailSettings.ByPassEmail {
c.Err = model.NewAppError("login", "Login failed because email address has not been verified", extraInfo)
c.Err.StatusCode = http.StatusForbidden
return

View File

@@ -54,11 +54,12 @@
"ProfileHeight": 128
},
"EmailSettings": {
"ByPassEmail" : true,
"SMTPUsername": "",
"SMTPPassword": "",
"SMTPServer": "",
"UseTLS": false,
"FeedbackEmail": "feedback@xxxxxxmustbefilledin.com",
"FeedbackEmail": "",
"FeedbackName": "",
"ApplePushServer": "",
"ApplePushCertPublic": "",

View File

@@ -54,9 +54,10 @@
"ProfileHeight": 128
},
"EmailSettings": {
"ByPassEmail" : true,
"SMTPUsername": "",
"SMTPPassword": "",
"SMTPServer": "localhost:25",
"SMTPServer": "",
"UseTLS": false,
"FeedbackEmail": "",
"FeedbackName": "",

View File

@@ -77,6 +77,7 @@ type ImageSettings struct {
}
type EmailSettings struct {
ByPassEmail bool
SMTPUsername string
SMTPPassword string
SMTPServer string

View File

@@ -8,14 +8,14 @@ import (
"crypto/tls"
"fmt"
"github.com/mattermost/platform/model"
"html"
"net"
"net/mail"
"net/smtp"
"html"
)
func CheckMailSettings() *model.AppError {
if len(Cfg.EmailSettings.SMTPServer) == 0 {
if len(Cfg.EmailSettings.SMTPServer) == 0 || Cfg.EmailSettings.ByPassEmail {
return model.NewAppError("CheckMailSettings", "No email settings present, mail will not be sent", "")
}
conn, err := connectToSMTPServer()
@@ -79,6 +79,10 @@ func newSMTPClient(conn net.Conn) (*smtp.Client, *model.AppError) {
func SendMail(to, subject, body string) *model.AppError {
if len(Cfg.EmailSettings.SMTPServer) == 0 || Cfg.EmailSettings.ByPassEmail {
return nil
}
fromMail := mail.Address{"", Cfg.EmailSettings.FeedbackEmail}
toMail := mail.Address{"", to}
@@ -95,11 +99,6 @@ func SendMail(to, subject, body string) *model.AppError {
}
message += "\r\n<html><body>" + body + "</body></html>"
if len(Cfg.EmailSettings.SMTPServer) == 0 {
l4g.Warn("Skipping sending of email because EmailSettings are not configured")
return nil
}
conn, err1 := connectToSMTPServer()
if err1 != nil {
return err1

View File

@@ -46,25 +46,24 @@ module.exports = React.createClass({
function(data) {
client.track('signup', 'signup_user_02_complete');
if (data.email_verified) {
client.loginByEmail(this.props.domain, this.state.user.email, this.state.user.password,
function(data) {
UserStore.setLastDomain(this.props.domain);
UserStore.setLastEmail(this.state.user.email);
UserStore.setCurrentUser(data);
if (this.props.hash > 0)
BrowserStore.setGlobalItem(this.props.hash, JSON.stringify({wizard: "finished"}));
window.location.href = '/channels/town-square';
}.bind(this),
function(err) {
client.loginByEmail(this.props.domain, this.state.user.email, this.state.user.password,
function(data) {
UserStore.setLastDomain(this.props.domain);
UserStore.setLastEmail(this.state.user.email);
UserStore.setCurrentUser(data);
if (this.props.hash > 0)
BrowserStore.setGlobalItem(this.props.hash, JSON.stringify({wizard: "finished"}));
window.location.href = '/channels/town-square';
}.bind(this),
function(err) {
if (err.message == "Login failed because email address has not been verified") {
window.location.href = "/verify?email="+ encodeURIComponent(this.state.user.email) + "&domain=" + encodeURIComponent(this.props.domain);
} else {
this.state.server_error = err.message;
this.setState(this.state);
}.bind(this)
);
}
else {
window.location.href = "/verify?email="+ encodeURIComponent(this.state.user.email) + "&domain=" + encodeURIComponent(this.props.domain);
}
}
}.bind(this)
);
}.bind(this),
function(err) {
this.state.server_error = err.message;