mirror of
https://github.com/mattermost/mattermost.git
synced 2025-02-25 18:55:24 -06:00
Fixes mm-1415 adding email bypass flag
This commit is contained in:
@@ -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"]
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -54,11 +54,12 @@
|
||||
"ProfileHeight": 128
|
||||
},
|
||||
"EmailSettings": {
|
||||
"ByPassEmail" : true,
|
||||
"SMTPUsername": "",
|
||||
"SMTPPassword": "",
|
||||
"SMTPServer": "",
|
||||
"UseTLS": false,
|
||||
"FeedbackEmail": "feedback@xxxxxxmustbefilledin.com",
|
||||
"FeedbackEmail": "",
|
||||
"FeedbackName": "",
|
||||
"ApplePushServer": "",
|
||||
"ApplePushCertPublic": "",
|
||||
|
||||
@@ -54,9 +54,10 @@
|
||||
"ProfileHeight": 128
|
||||
},
|
||||
"EmailSettings": {
|
||||
"ByPassEmail" : true,
|
||||
"SMTPUsername": "",
|
||||
"SMTPPassword": "",
|
||||
"SMTPServer": "localhost:25",
|
||||
"SMTPServer": "",
|
||||
"UseTLS": false,
|
||||
"FeedbackEmail": "",
|
||||
"FeedbackName": "",
|
||||
|
||||
@@ -77,6 +77,7 @@ type ImageSettings struct {
|
||||
}
|
||||
|
||||
type EmailSettings struct {
|
||||
ByPassEmail bool
|
||||
SMTPUsername string
|
||||
SMTPPassword string
|
||||
SMTPServer string
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user