Skip to content

Commit

Permalink
fix: check if session is nil (#1873)
Browse files Browse the repository at this point in the history
## What kind of change does this PR introduce?
* Log a message if the session is nil
  • Loading branch information
kangmingtay authored Dec 13, 2024
1 parent a6918f4 commit fd82601
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions internal/api/logout.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"fmt"
"net/http"

"github.com/sirupsen/logrus"
"github.com/supabase/auth/internal/models"
"github.com/supabase/auth/internal/storage"
)
Expand Down Expand Up @@ -46,13 +47,17 @@ func (a *API) Logout(w http.ResponseWriter, r *http.Request) error {
return terr
}

//exhaustive:ignore Default case is handled below.
switch scope {
case LogoutLocal:
return models.LogoutSession(tx, s.ID)

case LogoutOthers:
return models.LogoutAllExceptMe(tx, s.ID, u.ID)
if s == nil {
logrus.Infof("user has an empty session_id claim: %s", u.ID)
} else {
//exhaustive:ignore Default case is handled below.
switch scope {
case LogoutLocal:
return models.LogoutSession(tx, s.ID)

case LogoutOthers:
return models.LogoutAllExceptMe(tx, s.ID, u.ID)
}
}

// default mode, log out everywhere
Expand Down

0 comments on commit fd82601

Please sign in to comment.