Skip to content

Commit

Permalink
feat: return userID on session validation endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
FreddyDevelop committed Oct 11, 2024
1 parent b6369e9 commit cf4d4b5
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
2 changes: 2 additions & 0 deletions backend/handler/session.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,11 @@ func (h *SessionHandler) ValidateSession(c echo.Context) error {

if token != nil {
expirationTime := token.Expiration()
userID := uuid.FromStringOrNil(token.Subject())
return c.JSON(http.StatusOK, ValidateSessionResponse{
IsValid: true,
ExpirationTime: &expirationTime,
UserID: &userID,
})
} else {
return c.JSON(http.StatusOK, ValidateSessionResponse{IsValid: false})
Expand Down
3 changes: 3 additions & 0 deletions backend/handler/session_admin.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ type ValidateSessionRequest struct {
type ValidateSessionResponse struct {
IsValid bool `json:"is_valid"`
ExpirationTime *time.Time `json:"expiration_time,omitempty"`
UserID *uuid.UUID `json:"user_id,omitempty"`
}

func (h *SessionHandlerAdmin) ValidateSession(c echo.Context) error {
Expand Down Expand Up @@ -75,8 +76,10 @@ func (h *SessionHandlerAdmin) ValidateSession(c echo.Context) error {
}

expirationTime := token.Expiration()
userID := uuid.FromStringOrNil(token.Subject())
return c.JSON(http.StatusOK, ValidateSessionResponse{
IsValid: true,
ExpirationTime: &expirationTime,
UserID: &userID,
})
}

0 comments on commit cf4d4b5

Please sign in to comment.