diff options
author | Elias Nahum <nahumhbl@gmail.com> | 2016-08-09 17:05:59 -0500 |
---|---|---|
committer | Elias Nahum <nahumhbl@gmail.com> | 2016-08-09 17:05:59 -0500 |
commit | 805659239098a0b382a2a8bad704c2e91ab38ed6 (patch) | |
tree | e2c42b89d7ffc830bd9270cc65780fe470ccb4f4 /api | |
parent | 7be82c2b279390d3659fbe74c7d3ccabc48a6dd8 (diff) | |
parent | ac2f75ac8fd4e2d7ae1de6703a156b9636d4b8f0 (diff) | |
download | chat-805659239098a0b382a2a8bad704c2e91ab38ed6.tar.gz chat-805659239098a0b382a2a8bad704c2e91ab38ed6.tar.bz2 chat-805659239098a0b382a2a8bad704c2e91ab38ed6.zip |
Merge branch 'release-3.3' RC3
Diffstat (limited to 'api')
-rw-r--r-- | api/context.go | 16 | ||||
-rw-r--r-- | api/oauth.go | 6 | ||||
-rw-r--r-- | api/post.go | 1 |
3 files changed, 15 insertions, 8 deletions
diff --git a/api/context.go b/api/context.go index 08f41aa6d..c0e6bf3b5 100644 --- a/api/context.go +++ b/api/context.go @@ -39,6 +39,7 @@ type Context struct { Err *model.AppError teamURLValid bool teamURL string + siteURL string T goi18n.TranslateFunc Locale string TeamId string @@ -141,10 +142,11 @@ func (h handler) ServeHTTP(w http.ResponseWriter, r *http.Request) { isTokenFromQueryString = true } - // if the site url in the config isn't specified, infer if from this request and write it back to the config - if *utils.Cfg.ServiceSettings.SiteURL == "" { - *utils.Cfg.ServiceSettings.SiteURL = GetProtocol(r) + "://" + r.Host - utils.RegenerateClientConfig() + if *utils.Cfg.ServiceSettings.SiteURL != "" { + c.SetSiteURL(*utils.Cfg.ServiceSettings.SiteURL) + } else { + protocol := GetProtocol(r) + c.SetSiteURL(protocol + "://" + r.Host) } w.Header().Set(model.HEADER_REQUEST_ID, c.RequestId) @@ -439,6 +441,10 @@ func (c *Context) SetTeamURLFromSession() { } } +func (c *Context) SetSiteURL(url string) { + c.siteURL = url +} + func (c *Context) GetTeamURLFromTeam(team *model.Team) string { return c.GetSiteURL() + "/" + team.Name } @@ -454,7 +460,7 @@ func (c *Context) GetTeamURL() string { } func (c *Context) GetSiteURL() string { - return *utils.Cfg.ServiceSettings.SiteURL + return c.siteURL } func IsApiCall(r *http.Request) bool { diff --git a/api/oauth.go b/api/oauth.go index e2ea001a0..fe2ecf166 100644 --- a/api/oauth.go +++ b/api/oauth.go @@ -33,11 +33,11 @@ func InitOAuth() { BaseRoutes.OAuth.Handle("/{service:[A-Za-z0-9]+}/complete", AppHandlerIndependent(completeOAuth)).Methods("GET") BaseRoutes.OAuth.Handle("/{service:[A-Za-z0-9]+}/login", AppHandlerIndependent(loginWithOAuth)).Methods("GET") BaseRoutes.OAuth.Handle("/{service:[A-Za-z0-9]+}/signup", AppHandlerIndependent(signupWithOAuth)).Methods("GET") - BaseRoutes.OAuth.Handle("/authorize", ApiUserRequired(authorizeOAuth)).Methods("GET") - BaseRoutes.OAuth.Handle("/access_token", ApiAppHandler(getAccessToken)).Methods("POST") + BaseRoutes.OAuth.Handle("/authorize", AppHandlerTrustRequester(authorizeOAuth)).Methods("GET") + BaseRoutes.OAuth.Handle("/access_token", ApiAppHandlerTrustRequester(getAccessToken)).Methods("POST") BaseRoutes.Root.Handle("/authorize", AppHandlerTrustRequester(authorizeOAuth)).Methods("GET") - BaseRoutes.Root.Handle("/access_token", ApiAppHandler(getAccessToken)).Methods("POST") + BaseRoutes.Root.Handle("/access_token", ApiAppHandlerTrustRequester(getAccessToken)).Methods("POST") // Handle all the old routes, to be later removed BaseRoutes.Root.Handle("/{service:[A-Za-z0-9]+}/complete", AppHandlerIndependent(completeOAuth)).Methods("GET") diff --git a/api/post.go b/api/post.go index 0c7654df1..d32d1c6a5 100644 --- a/api/post.go +++ b/api/post.go @@ -458,6 +458,7 @@ func handleWebhookEvents(c *Context, post *model.Post, team *model.Team, channel Err: nil, teamURLValid: c.teamURLValid, teamURL: c.teamURL, + siteURL: c.siteURL, T: c.T, Locale: c.Locale, TeamId: hook.TeamId, |