Skip to content

Commit fd82601

Browse files
authored
fix: check if session is nil (#1873)
## What kind of change does this PR introduce? * Log a message if the session is nil
1 parent a6918f4 commit fd82601

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

internal/api/logout.go

+12-7
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"fmt"
55
"net/http"
66

7+
"github.com/sirupsen/logrus"
78
"github.com/supabase/auth/internal/models"
89
"github.com/supabase/auth/internal/storage"
910
)
@@ -46,13 +47,17 @@ func (a *API) Logout(w http.ResponseWriter, r *http.Request) error {
4647
return terr
4748
}
4849

49-
//exhaustive:ignore Default case is handled below.
50-
switch scope {
51-
case LogoutLocal:
52-
return models.LogoutSession(tx, s.ID)
53-
54-
case LogoutOthers:
55-
return models.LogoutAllExceptMe(tx, s.ID, u.ID)
50+
if s == nil {
51+
logrus.Infof("user has an empty session_id claim: %s", u.ID)
52+
} else {
53+
//exhaustive:ignore Default case is handled below.
54+
switch scope {
55+
case LogoutLocal:
56+
return models.LogoutSession(tx, s.ID)
57+
58+
case LogoutOthers:
59+
return models.LogoutAllExceptMe(tx, s.ID, u.ID)
60+
}
5661
}
5762

5863
// default mode, log out everywhere

0 commit comments

Comments
 (0)