MCPcopy Create free account
hub / github.com/couchbase/sync_gateway / deleteUserSessionWithValidation

Method deleteUserSessionWithValidation

rest/session_api.go:296–314  ·  view source on GitHub ↗

Delete a session if associated with the user provided

(sessionId string, userName string)

Source from the content-addressed store, hash-verified

294
295// Delete a session if associated with the user provided
296func (h *handler) deleteUserSessionWithValidation(sessionId string, userName string) error {
297
298 // Validate that the session being deleted belongs to the user. This adds some
299 // overhead - for user-agnostic session deletion should use deleteSession
300 session, _, getErr := h.db.Authenticator(h.ctx()).GetSession(sessionId)
301 if getErr != nil {
302 return getErr
303 }
304
305 if session.Username == userName {
306 delErr := h.db.Authenticator(h.ctx()).DeleteSession(h.ctx(), sessionId, userName)
307 if delErr != nil {
308 return delErr
309 }
310 } else {
311 return kNotFoundError
312 }
313 return nil
314}
315
316// Respond with a JSON struct containing info about the current login session
317func (h *handler) respondWithSessionInfoForSession(session *auth.LoginSession) error {

Callers 1

deleteUserSessionMethod · 0.95

Calls 4

ctxMethod · 0.95
GetSessionMethod · 0.80
DeleteSessionMethod · 0.80
AuthenticatorMethod · 0.45

Tested by

no test coverage detected