MCPcopy Create free account
hub / github.com/netlify/gotrue / Logout

Method Logout

api/logout.go:11–34  ·  view source on GitHub ↗

Logout is the endpoint for logging out a user and thereby revoking any refresh tokens

(w http.ResponseWriter, r *http.Request)

Source from the content-addressed store, hash-verified

9
10// Logout is the endpoint for logging out a user and thereby revoking any refresh tokens
11func (a *API) Logout(w http.ResponseWriter, r *http.Request) error {
12 ctx := r.Context()
13 instanceID := getInstanceID(ctx)
14
15 a.clearCookieToken(ctx, w)
16
17 u, err := getUserFromClaims(ctx, a.db)
18 if err != nil {
19 return unauthorizedError("Invalid user").WithInternalError(err)
20 }
21
22 err = a.db.Transaction(func(tx *storage.Connection) error {
23 if terr := models.NewAuditLogEntry(tx, instanceID, u, models.LogoutAction, nil); terr != nil {
24 return terr
25 }
26 return models.Logout(tx, instanceID, u.ID)
27 })
28 if err != nil {
29 return internalServerError("Error logging out user").WithInternalError(err)
30 }
31
32 w.WriteHeader(http.StatusNoContent)
33 return nil
34}

Callers

nothing calls this directly

Calls 10

clearCookieTokenMethod · 0.95
NewAuditLogEntryFunction · 0.92
LogoutFunction · 0.92
getInstanceIDFunction · 0.85
getUserFromClaimsFunction · 0.85
unauthorizedErrorFunction · 0.85
internalServerErrorFunction · 0.85
TransactionMethod · 0.80
WriteHeaderMethod · 0.80
WithInternalErrorMethod · 0.45

Tested by

no test coverage detected