Merge pull request #171 from mattermost/mm-1415

Fixes mm-1415 adding email bypass flag
Этот коммит содержится в:
Corey Hulen
2015-07-15 10:27:24 -08:00
родитель 38f9e140e9 e017babc5d
Коммит d16a1d6d75
7 изменённых файлов: 29 добавлений и 28 удалений

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

@@ -68,7 +68,7 @@ func signupTeam(c *Context, w http.ResponseWriter, r *http.Request) {
return 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"] m["follow_link"] = bodyPage.Props["Link"]
} }

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

@@ -293,7 +293,7 @@ func login(c *Context, w http.ResponseWriter, r *http.Request) {
return 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 = model.NewAppError("login", "Login failed because email address has not been verified", extraInfo)
c.Err.StatusCode = http.StatusForbidden c.Err.StatusCode = http.StatusForbidden
return return

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

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

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

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

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

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

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

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

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

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