Delete a session if associated with the user provided
(sessionId string, userName string)
| 294 | |
| 295 | // Delete a session if associated with the user provided |
| 296 | func (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 |
| 317 | func (h *handler) respondWithSessionInfoForSession(session *auth.LoginSession) error { |
no test coverage detected