Add ability to use 'me' in place of user id for APIv4 (#5826)
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
fd6e2f3f73
Коммит
bea49cbcf3
@@ -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")
|
||||
}
|
||||
|
||||
@@ -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()
|
||||
|
||||
Ссылка в новой задаче
Block a user