fix
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user