Remove global site url (#8343)
* remove global site url * missed one * revert mysterious change
Этот коммит содержится в:
@@ -752,7 +752,7 @@ func sendPasswordReset(c *Context, w http.ResponseWriter, r *http.Request) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if sent, err := c.App.SendPasswordReset(email, utils.GetSiteURL()); err != nil {
|
if sent, err := c.App.SendPasswordReset(email, c.App.GetSiteURL()); err != nil {
|
||||||
c.Err = err
|
c.Err = err
|
||||||
return
|
return
|
||||||
} else if sent {
|
} else if sent {
|
||||||
@@ -1046,7 +1046,7 @@ func updateMfa(c *Context, w http.ResponseWriter, r *http.Request) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := c.App.SendMfaChangeEmail(user.Email, activate, user.Locale, utils.GetSiteURL()); err != nil {
|
if err := c.App.SendMfaChangeEmail(user.Email, activate, user.Locale, c.App.GetSiteURL()); err != nil {
|
||||||
l4g.Error(err.Error())
|
l4g.Error(err.Error())
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@@ -1180,7 +1180,7 @@ func completeSaml(c *Context, w http.ResponseWriter, r *http.Request) {
|
|||||||
}
|
}
|
||||||
c.LogAuditWithUserId(user.Id, "Revoked all sessions for user")
|
c.LogAuditWithUserId(user.Id, "Revoked all sessions for user")
|
||||||
c.App.Go(func() {
|
c.App.Go(func() {
|
||||||
if err := c.App.SendSignInChangeEmail(user.Email, strings.Title(model.USER_AUTH_SERVICE_SAML)+" SSO", user.Locale, utils.GetSiteURL()); err != nil {
|
if err := c.App.SendSignInChangeEmail(user.Email, strings.Title(model.USER_AUTH_SERVICE_SAML)+" SSO", user.Locale, c.App.GetSiteURL()); err != nil {
|
||||||
l4g.Error(err.Error())
|
l4g.Error(err.Error())
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -13,7 +13,6 @@ import (
|
|||||||
"github.com/mattermost/mattermost-server/app"
|
"github.com/mattermost/mattermost-server/app"
|
||||||
"github.com/mattermost/mattermost-server/model"
|
"github.com/mattermost/mattermost-server/model"
|
||||||
"github.com/mattermost/mattermost-server/store"
|
"github.com/mattermost/mattermost-server/store"
|
||||||
"github.com/mattermost/mattermost-server/utils"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func (api *API) InitUser() {
|
func (api *API) InitUser() {
|
||||||
@@ -894,7 +893,7 @@ func sendPasswordReset(c *Context, w http.ResponseWriter, r *http.Request) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if sent, err := c.App.SendPasswordReset(email, utils.GetSiteURL()); err != nil {
|
if sent, err := c.App.SendPasswordReset(email, c.App.GetSiteURL()); err != nil {
|
||||||
c.Err = err
|
c.Err = err
|
||||||
return
|
return
|
||||||
} else if sent {
|
} else if sent {
|
||||||
|
|||||||
@@ -63,6 +63,8 @@ type App struct {
|
|||||||
clientLicenseValue atomic.Value
|
clientLicenseValue atomic.Value
|
||||||
licenseListeners map[string]func()
|
licenseListeners map[string]func()
|
||||||
|
|
||||||
|
siteURL string
|
||||||
|
|
||||||
newStore func() store.Store
|
newStore func() store.Store
|
||||||
|
|
||||||
htmlTemplateWatcher *utils.HTMLTemplateWatcher
|
htmlTemplateWatcher *utils.HTMLTemplateWatcher
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"net/url"
|
"net/url"
|
||||||
"runtime/debug"
|
"runtime/debug"
|
||||||
|
"strings"
|
||||||
|
|
||||||
l4g "github.com/alecthomas/log4go"
|
l4g "github.com/alecthomas/log4go"
|
||||||
|
|
||||||
@@ -54,7 +55,7 @@ func (a *App) LoadConfig(configFile string) *model.AppError {
|
|||||||
|
|
||||||
a.config.Store(cfg)
|
a.config.Store(cfg)
|
||||||
|
|
||||||
utils.SetSiteURL(*cfg.ServiceSettings.SiteURL)
|
a.siteURL = strings.TrimRight(*cfg.ServiceSettings.SiteURL, "/")
|
||||||
|
|
||||||
a.InvokeConfigListeners(old, cfg)
|
a.InvokeConfigListeners(old, cfg)
|
||||||
return nil
|
return nil
|
||||||
@@ -264,3 +265,7 @@ func (a *App) GetCookieDomain() string {
|
|||||||
}
|
}
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (a *App) GetSiteURL() string {
|
||||||
|
return a.siteURL
|
||||||
|
}
|
||||||
|
|||||||
@@ -191,7 +191,7 @@ func (a *App) SendUserAccessTokenAddedEmail(email, locale string) *model.AppErro
|
|||||||
bodyPage := a.NewEmailTemplate("password_change_body", locale)
|
bodyPage := a.NewEmailTemplate("password_change_body", locale)
|
||||||
bodyPage.Props["Title"] = T("api.templates.user_access_token_body.title")
|
bodyPage.Props["Title"] = T("api.templates.user_access_token_body.title")
|
||||||
bodyPage.Html["Info"] = utils.TranslateAsHtml(T, "api.templates.user_access_token_body.info",
|
bodyPage.Html["Info"] = utils.TranslateAsHtml(T, "api.templates.user_access_token_body.info",
|
||||||
map[string]interface{}{"SiteName": a.ClientConfig()["SiteName"], "SiteURL": utils.GetSiteURL()})
|
map[string]interface{}{"SiteName": a.ClientConfig()["SiteName"], "SiteURL": a.GetSiteURL()})
|
||||||
|
|
||||||
if err := a.SendMail(email, subject, bodyPage.Render()); err != nil {
|
if err := a.SendMail(email, subject, bodyPage.Render()); err != nil {
|
||||||
return model.NewAppError("SendUserAccessTokenAddedEmail", "api.user.send_user_access_token.error", nil, err.Error(), http.StatusInternalServerError)
|
return model.NewAppError("SendUserAccessTokenAddedEmail", "api.user.send_user_access_token.error", nil, err.Error(), http.StatusInternalServerError)
|
||||||
|
|||||||
@@ -67,7 +67,7 @@ func (a *App) SwitchEmailToLdap(email, password, code, ldapId, ldapPassword stri
|
|||||||
}
|
}
|
||||||
|
|
||||||
a.Go(func() {
|
a.Go(func() {
|
||||||
if err := a.SendSignInChangeEmail(user.Email, "AD/LDAP", user.Locale, utils.GetSiteURL()); err != nil {
|
if err := a.SendSignInChangeEmail(user.Email, "AD/LDAP", user.Locale, a.GetSiteURL()); err != nil {
|
||||||
l4g.Error(err.Error())
|
l4g.Error(err.Error())
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@@ -113,7 +113,7 @@ func (a *App) SwitchLdapToEmail(ldapPassword, code, email, newPassword string) (
|
|||||||
T := utils.GetUserTranslations(user.Locale)
|
T := utils.GetUserTranslations(user.Locale)
|
||||||
|
|
||||||
a.Go(func() {
|
a.Go(func() {
|
||||||
if err := a.SendSignInChangeEmail(user.Email, T("api.templates.signin_change_email.body.method_email"), user.Locale, utils.GetSiteURL()); err != nil {
|
if err := a.SendSignInChangeEmail(user.Email, T("api.templates.signin_change_email.body.method_email"), user.Locale, a.GetSiteURL()); err != nil {
|
||||||
l4g.Error(err.Error())
|
l4g.Error(err.Error())
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -362,7 +362,7 @@ func (a *App) sendNotificationEmail(post *model.Post, user *model.User, channel
|
|||||||
emailNotificationContentsType = *a.Config().EmailSettings.EmailNotificationContentsType
|
emailNotificationContentsType = *a.Config().EmailSettings.EmailNotificationContentsType
|
||||||
}
|
}
|
||||||
|
|
||||||
teamURL := utils.GetSiteURL() + "/" + team.Name
|
teamURL := a.GetSiteURL() + "/" + team.Name
|
||||||
var bodyText = a.getNotificationEmailBody(user, post, channel, senderName, team.Name, teamURL, emailNotificationContentsType, translateFunc)
|
var bodyText = a.getNotificationEmailBody(user, post, channel, senderName, team.Name, teamURL, emailNotificationContentsType, translateFunc)
|
||||||
|
|
||||||
a.Go(func() {
|
a.Go(func() {
|
||||||
@@ -421,7 +421,7 @@ func (a *App) getNotificationEmailBody(recipient *model.User, post *model.Post,
|
|||||||
bodyPage = a.NewEmailTemplate("post_body_generic", recipient.Locale)
|
bodyPage = a.NewEmailTemplate("post_body_generic", recipient.Locale)
|
||||||
}
|
}
|
||||||
|
|
||||||
bodyPage.Props["SiteURL"] = utils.GetSiteURL()
|
bodyPage.Props["SiteURL"] = a.GetSiteURL()
|
||||||
if teamName != "select_team" {
|
if teamName != "select_team" {
|
||||||
bodyPage.Props["TeamLink"] = teamURL + "/pl/" + post.Id
|
bodyPage.Props["TeamLink"] = teamURL + "/pl/" + post.Id
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -527,7 +527,7 @@ func (a *App) CompleteSwitchWithOAuth(service string, userData io.ReadCloser, em
|
|||||||
}
|
}
|
||||||
|
|
||||||
a.Go(func() {
|
a.Go(func() {
|
||||||
if err := a.SendSignInChangeEmail(user.Email, strings.Title(service)+" SSO", user.Locale, utils.GetSiteURL()); err != nil {
|
if err := a.SendSignInChangeEmail(user.Email, strings.Title(service)+" SSO", user.Locale, a.GetSiteURL()); err != nil {
|
||||||
l4g.Error(err.Error())
|
l4g.Error(err.Error())
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@@ -600,7 +600,7 @@ func (a *App) GetAuthorizationCode(w http.ResponseWriter, r *http.Request, servi
|
|||||||
props["token"] = stateToken.Token
|
props["token"] = stateToken.Token
|
||||||
state := b64.StdEncoding.EncodeToString([]byte(model.MapToJson(props)))
|
state := b64.StdEncoding.EncodeToString([]byte(model.MapToJson(props)))
|
||||||
|
|
||||||
redirectUri := utils.GetSiteURL() + "/signup/" + service + "/complete"
|
redirectUri := a.GetSiteURL() + "/signup/" + service + "/complete"
|
||||||
|
|
||||||
authUrl := endpoint + "?response_type=code&client_id=" + clientId + "&redirect_uri=" + url.QueryEscape(redirectUri) + "&state=" + url.QueryEscape(state)
|
authUrl := endpoint + "?response_type=code&client_id=" + clientId + "&redirect_uri=" + url.QueryEscape(redirectUri) + "&state=" + url.QueryEscape(state)
|
||||||
|
|
||||||
@@ -736,7 +736,7 @@ func (a *App) SwitchEmailToOAuth(w http.ResponseWriter, r *http.Request, email,
|
|||||||
stateProps["email"] = email
|
stateProps["email"] = email
|
||||||
|
|
||||||
if service == model.USER_AUTH_SERVICE_SAML {
|
if service == model.USER_AUTH_SERVICE_SAML {
|
||||||
return utils.GetSiteURL() + "/login/sso/saml?action=" + model.OAUTH_ACTION_EMAIL_TO_SSO + "&email=" + utils.UrlEncode(email), nil
|
return a.GetSiteURL() + "/login/sso/saml?action=" + model.OAUTH_ACTION_EMAIL_TO_SSO + "&email=" + utils.UrlEncode(email), nil
|
||||||
} else {
|
} else {
|
||||||
if authUrl, err := a.GetAuthorizationCode(w, r, service, stateProps, ""); err != nil {
|
if authUrl, err := a.GetAuthorizationCode(w, r, service, stateProps, ""); err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
@@ -768,7 +768,7 @@ func (a *App) SwitchOAuthToEmail(email, password, requesterId string) (string, *
|
|||||||
T := utils.GetUserTranslations(user.Locale)
|
T := utils.GetUserTranslations(user.Locale)
|
||||||
|
|
||||||
a.Go(func() {
|
a.Go(func() {
|
||||||
if err := a.SendSignInChangeEmail(user.Email, T("api.templates.signin_change_email.body.method_email"), user.Locale, utils.GetSiteURL()); err != nil {
|
if err := a.SendSignInChangeEmail(user.Email, T("api.templates.signin_change_email.body.method_email"), user.Locale, a.GetSiteURL()); err != nil {
|
||||||
l4g.Error(err.Error())
|
l4g.Error(err.Error())
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -741,7 +741,7 @@ func (a *App) InviteNewUsersToTeam(emailList []string, teamId, senderId string)
|
|||||||
}
|
}
|
||||||
|
|
||||||
nameFormat := *a.Config().TeamSettings.TeammateNameDisplay
|
nameFormat := *a.Config().TeamSettings.TeammateNameDisplay
|
||||||
a.SendInviteEmails(team, user.GetDisplayName(nameFormat), emailList, utils.GetSiteURL())
|
a.SendInviteEmails(team, user.GetDisplayName(nameFormat), emailList, a.GetSiteURL())
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|||||||
18
app/user.go
18
app/user.go
@@ -106,7 +106,7 @@ func (a *App) CreateUserWithInviteId(user *model.User, inviteId string) (*model.
|
|||||||
|
|
||||||
a.AddDirectChannels(team.Id, ruser)
|
a.AddDirectChannels(team.Id, ruser)
|
||||||
|
|
||||||
if err := a.SendWelcomeEmail(ruser.Id, ruser.Email, ruser.EmailVerified, ruser.Locale, utils.GetSiteURL()); err != nil {
|
if err := a.SendWelcomeEmail(ruser.Id, ruser.Email, ruser.EmailVerified, ruser.Locale, a.GetSiteURL()); err != nil {
|
||||||
l4g.Error(err.Error())
|
l4g.Error(err.Error())
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -119,7 +119,7 @@ func (a *App) CreateUserAsAdmin(user *model.User) (*model.User, *model.AppError)
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := a.SendWelcomeEmail(ruser.Id, ruser.Email, ruser.EmailVerified, ruser.Locale, utils.GetSiteURL()); err != nil {
|
if err := a.SendWelcomeEmail(ruser.Id, ruser.Email, ruser.EmailVerified, ruser.Locale, a.GetSiteURL()); err != nil {
|
||||||
l4g.Error(err.Error())
|
l4g.Error(err.Error())
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -143,7 +143,7 @@ func (a *App) CreateUserFromSignup(user *model.User) (*model.User, *model.AppErr
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := a.SendWelcomeEmail(ruser.Id, ruser.Email, ruser.EmailVerified, ruser.Locale, utils.GetSiteURL()); err != nil {
|
if err := a.SendWelcomeEmail(ruser.Id, ruser.Email, ruser.EmailVerified, ruser.Locale, a.GetSiteURL()); err != nil {
|
||||||
l4g.Error(err.Error())
|
l4g.Error(err.Error())
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1027,7 +1027,7 @@ func (a *App) UpdateUser(user *model.User, sendNotifications bool) (*model.User,
|
|||||||
if sendNotifications {
|
if sendNotifications {
|
||||||
if rusers[0].Email != rusers[1].Email {
|
if rusers[0].Email != rusers[1].Email {
|
||||||
a.Go(func() {
|
a.Go(func() {
|
||||||
if err := a.SendEmailChangeEmail(rusers[1].Email, rusers[0].Email, rusers[0].Locale, utils.GetSiteURL()); err != nil {
|
if err := a.SendEmailChangeEmail(rusers[1].Email, rusers[0].Email, rusers[0].Locale, a.GetSiteURL()); err != nil {
|
||||||
l4g.Error(err.Error())
|
l4g.Error(err.Error())
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@@ -1041,7 +1041,7 @@ func (a *App) UpdateUser(user *model.User, sendNotifications bool) (*model.User,
|
|||||||
|
|
||||||
if rusers[0].Username != rusers[1].Username {
|
if rusers[0].Username != rusers[1].Username {
|
||||||
a.Go(func() {
|
a.Go(func() {
|
||||||
if err := a.SendChangeUsernameEmail(rusers[1].Username, rusers[0].Username, rusers[0].Email, rusers[0].Locale, utils.GetSiteURL()); err != nil {
|
if err := a.SendChangeUsernameEmail(rusers[1].Username, rusers[0].Username, rusers[0].Email, rusers[0].Locale, a.GetSiteURL()); err != nil {
|
||||||
l4g.Error(err.Error())
|
l4g.Error(err.Error())
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@@ -1091,7 +1091,7 @@ func (a *App) UpdateMfa(activate bool, userId, token string) *model.AppError {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := a.SendMfaChangeEmail(user.Email, activate, user.Locale, utils.GetSiteURL()); err != nil {
|
if err := a.SendMfaChangeEmail(user.Email, activate, user.Locale, a.GetSiteURL()); err != nil {
|
||||||
l4g.Error(err.Error())
|
l4g.Error(err.Error())
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@@ -1129,7 +1129,7 @@ func (a *App) UpdatePasswordSendEmail(user *model.User, newPassword, method stri
|
|||||||
}
|
}
|
||||||
|
|
||||||
a.Go(func() {
|
a.Go(func() {
|
||||||
if err := a.SendPasswordChangeEmail(user.Email, method, user.Locale, utils.GetSiteURL()); err != nil {
|
if err := a.SendPasswordChangeEmail(user.Email, method, user.Locale, a.GetSiteURL()); err != nil {
|
||||||
l4g.Error(err.Error())
|
l4g.Error(err.Error())
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@@ -1342,9 +1342,9 @@ func (a *App) SendEmailVerification(user *model.User) *model.AppError {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if _, err := a.GetStatus(user.Id); err != nil {
|
if _, err := a.GetStatus(user.Id); err != nil {
|
||||||
return a.SendVerifyEmail(user.Email, user.Locale, utils.GetSiteURL(), token.Token)
|
return a.SendVerifyEmail(user.Email, user.Locale, a.GetSiteURL(), token.Token)
|
||||||
} else {
|
} else {
|
||||||
return a.SendEmailChangeVerifyEmail(user.Email, user.Locale, utils.GetSiteURL(), token.Token)
|
return a.SendEmailChangeVerifyEmail(user.Email, user.Locale, a.GetSiteURL(), token.Token)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ func RenderWebError(w http.ResponseWriter, r *http.Request, status int, params u
|
|||||||
http.Error(w, "", http.StatusInternalServerError)
|
http.Error(w, "", http.StatusInternalServerError)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
destination := strings.TrimRight(GetSiteURL(), "/") + "/error?" + queryString + "&s=" + base64.URLEncoding.EncodeToString(signature)
|
destination := "/error?" + queryString + "&s=" + base64.URLEncoding.EncodeToString(signature)
|
||||||
|
|
||||||
if status >= 300 && status < 400 {
|
if status >= 300 && status < 400 {
|
||||||
http.Redirect(w, r, destination, status)
|
http.Redirect(w, r, destination, status)
|
||||||
|
|||||||
@@ -34,15 +34,6 @@ const (
|
|||||||
)
|
)
|
||||||
|
|
||||||
var originalDisableDebugLvl l4g.Level = l4g.DEBUG
|
var originalDisableDebugLvl l4g.Level = l4g.DEBUG
|
||||||
var siteURL = ""
|
|
||||||
|
|
||||||
func GetSiteURL() string {
|
|
||||||
return siteURL
|
|
||||||
}
|
|
||||||
|
|
||||||
func SetSiteURL(url string) {
|
|
||||||
siteURL = strings.TrimRight(url, "/")
|
|
||||||
}
|
|
||||||
|
|
||||||
// FindConfigFile attempts to find an existing configuration file. fileName can be an absolute or
|
// FindConfigFile attempts to find an existing configuration file. fileName can be an absolute or
|
||||||
// relative path or name such as "/opt/mattermost/config.json" or simply "config.json". An empty
|
// relative path or name such as "/opt/mattermost/config.json" or simply "config.json". An empty
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user