Updates to session revoking in v4 (#7565)

Этот коммит содержится в:
Joram Wilander
2017-10-04 11:04:17 -04:00
коммит произвёл GitHub
родитель 3e144f82e2
Коммит affd35071e
3 изменённых файлов: 30 добавлений и 1 удалений

Просмотреть файл

@@ -926,7 +926,19 @@ func revokeSession(c *Context, w http.ResponseWriter, r *http.Request) {
return
}
if err := c.App.RevokeSessionById(sessionId); err != nil {
var session *model.Session
var err *model.AppError
if session, err = c.App.GetSessionById(sessionId); err != nil {
c.Err = err
return
}
if session.UserId != c.Params.UserId {
c.SetInvalidUrlParam("user_id")
return
}
if err := c.App.RevokeSession(session); err != nil {
c.Err = err
return
}

Просмотреть файл

@@ -1890,6 +1890,14 @@ func TestRevokeSessions(t *testing.T) {
}
CheckNoError(t, resp)
th.LoginBasic()
sessions, _ = th.App.GetSessions(th.SystemAdminUser.Id)
session = sessions[0]
_, resp = Client.RevokeSession(user.Id, session.Id)
CheckBadRequestStatus(t, resp)
Client.Logout()
_, resp = Client.RevokeSession(user.Id, model.NewId())
CheckUnauthorizedStatus(t, resp)