Skip to content

Commit

Permalink
feat(handler/login): log existing sid on prompt
Browse files Browse the repository at this point in the history
  • Loading branch information
tronghn committed Dec 19, 2023
1 parent 50e5333 commit 55839d7
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
4 changes: 4 additions & 0 deletions pkg/handler/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,10 @@ func (s *Standalone) Login(w http.ResponseWriter, r *http.Request) {

sess, _ := s.SessionManager.Get(r)
if sess != nil {
if sid := sess.ExternalSessionID(); sid != "" {
fields["sid"] = sid
}

err := s.SessionManager.Delete(r.Context(), sess)
if err != nil && !errors.Is(err, session.ErrNotFound) {
s.InternalError(w, r, fmt.Errorf("login: destroying session: %w", err))
Expand Down
6 changes: 5 additions & 1 deletion pkg/session/session.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,11 @@ func (in *Session) AuthTime() string {
}

func (in *Session) ExternalSessionID() string {
return in.data.ExternalSessionID
if in.data != nil {
return in.data.ExternalSessionID
}

return ""
}

func (in *Session) IDToken() string {
Expand Down

0 comments on commit 55839d7

Please sign in to comment.