summaryrefslogtreecommitdiffstats
path: root/api4
diff options
context:
space:
mode:
authorJoram Wilander <jwawilander@gmail.com>2017-02-20 15:35:02 -0500
committerCorey Hulen <corey@hulen.com>2017-02-20 15:35:02 -0500
commita5f8bdd3a073fa30bd9edd835bd2355c398efc8d (patch)
tree1805d203a14a8e1272b925178ae60522fc1eb7ec /api4
parent5272c0c17062d2b9ce14e295174bba1b3b35e514 (diff)
downloadchat-a5f8bdd3a073fa30bd9edd835bd2355c398efc8d.tar.gz
chat-a5f8bdd3a073fa30bd9edd835bd2355c398efc8d.tar.bz2
chat-a5f8bdd3a073fa30bd9edd835bd2355c398efc8d.zip
Various APIv4 fixes (#5474)
Diffstat (limited to 'api4')
-rw-r--r--api4/context.go2
-rw-r--r--api4/team.go2
-rw-r--r--api4/team_test.go4
3 files changed, 7 insertions, 1 deletions
diff --git a/api4/context.go b/api4/context.go
index d272e8049..f0d8b0c5c 100644
--- a/api4/context.go
+++ b/api4/context.go
@@ -128,6 +128,8 @@ func (h handler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
if utils.GetSiteURL() == "" {
protocol := app.GetProtocol(r)
c.SetSiteURL(protocol + "://" + r.Host)
+ } else {
+ c.SetSiteURL(utils.GetSiteURL())
}
w.Header().Set(model.HEADER_REQUEST_ID, c.RequestId)
diff --git a/api4/team.go b/api4/team.go
index 2e3b6b982..206ea7b0e 100644
--- a/api4/team.go
+++ b/api4/team.go
@@ -19,7 +19,7 @@ func InitTeam() {
BaseRoutes.TeamsForUser.Handle("", ApiSessionRequired(getTeamsForUser)).Methods("GET")
BaseRoutes.Team.Handle("", ApiSessionRequired(getTeam)).Methods("GET")
- BaseRoutes.Team.Handle("/stats", ApiHandler(getTeamStats)).Methods("GET")
+ BaseRoutes.Team.Handle("/stats", ApiSessionRequired(getTeamStats)).Methods("GET")
BaseRoutes.TeamByName.Handle("", ApiSessionRequired(getTeamByName)).Methods("GET")
BaseRoutes.TeamMember.Handle("", ApiSessionRequired(getTeamMember)).Methods("GET")
diff --git a/api4/team_test.go b/api4/team_test.go
index 32f1bc967..4381f903c 100644
--- a/api4/team_test.go
+++ b/api4/team_test.go
@@ -278,4 +278,8 @@ func TestGetTeamStats(t *testing.T) {
Client.Login(user.Email, user.Password)
_, resp = Client.GetTeamStats(th.BasicTeam.Id, "")
CheckForbiddenStatus(t, resp)
+
+ Client.Logout()
+ _, resp = Client.GetTeamStats(th.BasicTeam.Id, "")
+ CheckUnauthorizedStatus(t, resp)
}