summaryrefslogtreecommitdiffstats
path: root/api4
diff options
context:
space:
mode:
Diffstat (limited to 'api4')
-rw-r--r--api4/context.go4
-rw-r--r--api4/user_test.go17
2 files changed, 21 insertions, 0 deletions
diff --git a/api4/context.go b/api4/context.go
index fe2e8d35b..9fb1361bc 100644
--- a/api4/context.go
+++ b/api4/context.go
@@ -333,6 +333,10 @@ func (c *Context) RequireUserId() *Context {
return c
}
+ if c.Params.UserId == model.ME {
+ c.Params.UserId = c.Session.UserId
+ }
+
if len(c.Params.UserId) != 26 {
c.SetInvalidUrlParam("user_id")
}
diff --git a/api4/user_test.go b/api4/user_test.go
index 2e1a0adc2..923caa761 100644
--- a/api4/user_test.go
+++ b/api4/user_test.go
@@ -75,6 +75,23 @@ func TestCreateUser(t *testing.T) {
}
}
+func TestGetMe(t *testing.T) {
+ th := Setup().InitBasic()
+ defer TearDown()
+ Client := th.Client
+
+ ruser, resp := Client.GetMe("")
+ CheckNoError(t, resp)
+
+ if ruser.Id != th.BasicUser.Id {
+ t.Fatal("wrong user")
+ }
+
+ Client.Logout()
+ _, resp = Client.GetMe("")
+ CheckUnauthorizedStatus(t, resp)
+}
+
func TestGetUser(t *testing.T) {
th := Setup().InitBasic().InitSystemAdmin()
defer TearDown()