mirror of
https://github.com/lordmathis/lemma.git
synced 2025-11-05 23:44:22 +00:00
Migrate backend auth to cookies
This commit is contained in:
@@ -83,8 +83,14 @@ func (s *SessionService) RefreshSession(refreshToken string) (string, error) {
|
||||
}
|
||||
|
||||
// InvalidateSession removes a session with the given sessionID from the database
|
||||
func (s *SessionService) InvalidateSession(sessionID string) error {
|
||||
return s.db.DeleteSession(sessionID)
|
||||
func (s *SessionService) InvalidateSession(token string) error {
|
||||
// Parse the JWT to get the session info
|
||||
claims, err := s.jwtManager.ValidateToken(token)
|
||||
if err != nil {
|
||||
return fmt.Errorf("invalid token: %w", err)
|
||||
}
|
||||
|
||||
return s.db.DeleteSession(claims.ID)
|
||||
}
|
||||
|
||||
// CleanExpiredSessions removes all expired sessions from the database
|
||||
|
||||
Reference in New Issue
Block a user