This commit is contained in:
Giovanni Rezcjikov
2026-03-09 18:09:02 +03:00
parent be36c6f0c4
commit f188150c9f
25 changed files with 694 additions and 53 deletions
+10 -1
View File
@@ -3,6 +3,7 @@ package services
import (
"context"
"encoding/json"
"fmt"
"net/url"
"strings"
"time"
@@ -100,7 +101,12 @@ func (s *Service) SessionLogin(ctx context.Context, token, email, password strin
}
user, err := s.users.GetUserByEmail(ctx, email)
if err != nil || bcryptCompare(user.PasswordHash, password) != nil {
compareErr := error(nil)
if err == nil {
compareErr = bcryptCompare(user.PasswordHash, password)
}
if err != nil || compareErr != nil {
return "", ErrAccessDenied
}
@@ -321,6 +327,9 @@ func (s *Service) issuePair(ctx context.Context, user *models.User, clientID uui
return nil, models.ErrInternal
}
// Track issued access tokens per user and client to support revocation.
_ = s.redis.SAdd(ctx, fmt.Sprintf("user_client_tokens:%s:%s", user.ID, clientID), accessToken).Err()
_, err = s.oauth.CreateRefreshToken(ctx, models.RefreshTokenRow{
TokenHash: sha256Hex(rawRefresh),
UserID: user.ID,