Implement user sessions endpoints for APIv4 (#5449)
* added get session and revoke session endpoints, unittests and drivers * removed BasicUser2 and added teardown * added badrequest unit test case for sessions * added session loop to check if user id and session user id matches * fixed indentation issues for user_test * match indentation from spaces to tabs
Этот коммит содержится в:
коммит произвёл
Joram Wilander
родитель
2f96814a8b
Коммит
4e7dbc3bb0
@@ -403,6 +403,27 @@ func (c *Client4) ResetPassword(code, newPassword string) (bool, *Response) {
|
||||
}
|
||||
}
|
||||
|
||||
// GetSessions returns a list of sessions based on the provided user id string.
|
||||
func (c *Client4) GetSessions(userId, etag string) ([]*Session, *Response) {
|
||||
if r, err := c.DoApiGet(c.GetUserRoute(userId)+"/sessions", etag); err != nil {
|
||||
return nil, &Response{StatusCode: r.StatusCode, Error: err}
|
||||
} else {
|
||||
defer closeBody(r)
|
||||
return SessionsFromJson(r.Body), BuildResponse(r)
|
||||
}
|
||||
}
|
||||
|
||||
// RevokeSession revokes a user session based on the provided user id and session id strings.
|
||||
func (c *Client4) RevokeSession(userId, sessionId string) (bool, *Response) {
|
||||
requestBody := map[string]string{"session_id": sessionId}
|
||||
if r, err := c.DoApiPost(c.GetUserRoute(userId)+"/sessions/revoke", MapToJson(requestBody)); err != nil {
|
||||
return false, &Response{StatusCode: r.StatusCode, Error: err}
|
||||
} else {
|
||||
defer closeBody(r)
|
||||
return CheckStatusOK(r), BuildResponse(r)
|
||||
}
|
||||
}
|
||||
|
||||
// Team Section
|
||||
|
||||
// CreateTeam creates a team in the system based on the provided team struct.
|
||||
|
||||
Ссылка в новой задаче
Block a user