summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris <ccbrown112@gmail.com>2018-02-22 18:23:32 -0600
committerGitHub <noreply@github.com>2018-02-22 18:23:32 -0600
commitd44ef7ea67324072f3fbf1230c77f0ee0b4ac8bd (patch)
tree250e6f64e10631d6e0470e57916d82c897fc8b6a
parent1b3808f3ecf754876168a9342e18c46d49f32ddf (diff)
downloadchat-d44ef7ea67324072f3fbf1230c77f0ee0b4ac8bd.tar.gz
chat-d44ef7ea67324072f3fbf1230c77f0ee0b4ac8bd.tar.bz2
chat-d44ef7ea67324072f3fbf1230c77f0ee0b4ac8bd.zip
Remove global site url (#8343)
* remove global site url * missed one * revert mysterious change
-rw-r--r--api/user.go6
-rw-r--r--api4/user.go3
-rw-r--r--app/app.go2
-rw-r--r--app/config.go7
-rw-r--r--app/email.go2
-rw-r--r--app/ldap.go4
-rw-r--r--app/notification.go4
-rw-r--r--app/oauth.go8
-rw-r--r--app/team.go2
-rw-r--r--app/user.go18
-rw-r--r--utils/api.go2
-rw-r--r--utils/config.go9
12 files changed, 32 insertions, 35 deletions
diff --git a/api/user.go b/api/user.go
index ad4f12ef3..14cc881dc 100644
--- a/api/user.go
+++ b/api/user.go
@@ -752,7 +752,7 @@ func sendPasswordReset(c *Context, w http.ResponseWriter, r *http.Request) {
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
return
} else if sent {
@@ -1046,7 +1046,7 @@ func updateMfa(c *Context, w http.ResponseWriter, r *http.Request) {
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())
}
})
@@ -1180,7 +1180,7 @@ func completeSaml(c *Context, w http.ResponseWriter, r *http.Request) {
}
c.LogAuditWithUserId(user.Id, "Revoked all sessions for user")
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())
}
})
diff --git a/api4/user.go b/api4/user.go
index 165e5aa9a..f82a6e3d5 100644
--- a/api4/user.go
+++ b/api4/user.go
@@ -13,7 +13,6 @@ import (
"github.com/mattermost/mattermost-server/app"
"github.com/mattermost/mattermost-server/model"
"github.com/mattermost/mattermost-server/store"
- "github.com/mattermost/mattermost-server/utils"
)
func (api *API) InitUser() {
@@ -894,7 +893,7 @@ func sendPasswordReset(c *Context, w http.ResponseWriter, r *http.Request) {
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
return
} else if sent {
diff --git a/app/app.go b/app/app.go
index 636f0a428..26aed4c73 100644
--- a/app/app.go
+++ b/app/app.go
@@ -63,6 +63,8 @@ type App struct {
clientLicenseValue atomic.Value
licenseListeners map[string]func()
+ siteURL string
+
newStore func() store.Store
htmlTemplateWatcher *utils.HTMLTemplateWatcher
diff --git a/app/config.go b/app/config.go
index a9cd84d90..35a0c9a3f 100644
--- a/app/config.go
+++ b/app/config.go
@@ -14,6 +14,7 @@ import (
"fmt"
"net/url"
"runtime/debug"
+ "strings"
l4g "github.com/alecthomas/log4go"
@@ -54,7 +55,7 @@ func (a *App) LoadConfig(configFile string) *model.AppError {
a.config.Store(cfg)
- utils.SetSiteURL(*cfg.ServiceSettings.SiteURL)
+ a.siteURL = strings.TrimRight(*cfg.ServiceSettings.SiteURL, "/")
a.InvokeConfigListeners(old, cfg)
return nil
@@ -264,3 +265,7 @@ func (a *App) GetCookieDomain() string {
}
return ""
}
+
+func (a *App) GetSiteURL() string {
+ return a.siteURL
+}
diff --git a/app/email.go b/app/email.go
index 54a272a3b..8ee3e79e2 100644
--- a/app/email.go
+++ b/app/email.go
@@ -191,7 +191,7 @@ func (a *App) SendUserAccessTokenAddedEmail(email, locale string) *model.AppErro
bodyPage := a.NewEmailTemplate("password_change_body", locale)
bodyPage.Props["Title"] = T("api.templates.user_access_token_body.title")
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 {
return model.NewAppError("SendUserAccessTokenAddedEmail", "api.user.send_user_access_token.error", nil, err.Error(), http.StatusInternalServerError)
diff --git a/app/ldap.go b/app/ldap.go
index 179529c52..ff7a5ed21 100644
--- a/app/ldap.go
+++ b/app/ldap.go
@@ -67,7 +67,7 @@ func (a *App) SwitchEmailToLdap(email, password, code, ldapId, ldapPassword stri
}
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())
}
})
@@ -113,7 +113,7 @@ func (a *App) SwitchLdapToEmail(ldapPassword, code, email, newPassword string) (
T := utils.GetUserTranslations(user.Locale)
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())
}
})
diff --git a/app/notification.go b/app/notification.go
index 752e4bb12..8cb63fbaf 100644
--- a/app/notification.go
+++ b/app/notification.go
@@ -362,7 +362,7 @@ func (a *App) sendNotificationEmail(post *model.Post, user *model.User, channel
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)
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.Props["SiteURL"] = utils.GetSiteURL()
+ bodyPage.Props["SiteURL"] = a.GetSiteURL()
if teamName != "select_team" {
bodyPage.Props["TeamLink"] = teamURL + "/pl/" + post.Id
} else {
diff --git a/app/oauth.go b/app/oauth.go
index 5a66f542e..b9001ee0b 100644
--- a/app/oauth.go
+++ b/app/oauth.go
@@ -527,7 +527,7 @@ func (a *App) CompleteSwitchWithOAuth(service string, userData io.ReadCloser, em
}
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())
}
})
@@ -600,7 +600,7 @@ func (a *App) GetAuthorizationCode(w http.ResponseWriter, r *http.Request, servi
props["token"] = stateToken.Token
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)
@@ -736,7 +736,7 @@ func (a *App) SwitchEmailToOAuth(w http.ResponseWriter, r *http.Request, email,
stateProps["email"] = email
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 {
if authUrl, err := a.GetAuthorizationCode(w, r, service, stateProps, ""); err != nil {
return "", err
@@ -768,7 +768,7 @@ func (a *App) SwitchOAuthToEmail(email, password, requesterId string) (string, *
T := utils.GetUserTranslations(user.Locale)
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())
}
})
diff --git a/app/team.go b/app/team.go
index a15c64c3f..d8750bfbb 100644
--- a/app/team.go
+++ b/app/team.go
@@ -741,7 +741,7 @@ func (a *App) InviteNewUsersToTeam(emailList []string, teamId, senderId string)
}
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
}
diff --git a/app/user.go b/app/user.go
index 69c6d072b..f915f35cb 100644
--- a/app/user.go
+++ b/app/user.go
@@ -106,7 +106,7 @@ func (a *App) CreateUserWithInviteId(user *model.User, inviteId string) (*model.
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())
}
@@ -119,7 +119,7 @@ func (a *App) CreateUserAsAdmin(user *model.User) (*model.User, *model.AppError)
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())
}
@@ -143,7 +143,7 @@ func (a *App) CreateUserFromSignup(user *model.User) (*model.User, *model.AppErr
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())
}
@@ -1027,7 +1027,7 @@ func (a *App) UpdateUser(user *model.User, sendNotifications bool) (*model.User,
if sendNotifications {
if rusers[0].Email != rusers[1].Email {
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())
}
})
@@ -1041,7 +1041,7 @@ func (a *App) UpdateUser(user *model.User, sendNotifications bool) (*model.User,
if rusers[0].Username != rusers[1].Username {
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())
}
})
@@ -1091,7 +1091,7 @@ func (a *App) UpdateMfa(activate bool, userId, token string) *model.AppError {
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())
}
})
@@ -1129,7 +1129,7 @@ func (a *App) UpdatePasswordSendEmail(user *model.User, newPassword, method stri
}
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())
}
})
@@ -1342,9 +1342,9 @@ func (a *App) SendEmailVerification(user *model.User) *model.AppError {
}
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 {
- return a.SendEmailChangeVerifyEmail(user.Email, user.Locale, utils.GetSiteURL(), token.Token)
+ return a.SendEmailChangeVerifyEmail(user.Email, user.Locale, a.GetSiteURL(), token.Token)
}
}
diff --git a/utils/api.go b/utils/api.go
index 51524074d..0f2640829 100644
--- a/utils/api.go
+++ b/utils/api.go
@@ -52,7 +52,7 @@ func RenderWebError(w http.ResponseWriter, r *http.Request, status int, params u
http.Error(w, "", http.StatusInternalServerError)
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 {
http.Redirect(w, r, destination, status)
diff --git a/utils/config.go b/utils/config.go
index 0d3047c5d..afb2e758c 100644
--- a/utils/config.go
+++ b/utils/config.go
@@ -34,15 +34,6 @@ const (
)
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
// relative path or name such as "/opt/mattermost/config.json" or simply "config.json". An empty