mirror of
https://github.com/zitadel/zitadel.git
synced 2025-08-11 21:27:42 +00:00
fix(auth): always get token by id and user id (#4371)
Co-authored-by: Florian Forster <florian@zitadel.com>
This commit is contained in:
@@ -23,7 +23,7 @@ type TokenRepo struct {
|
||||
}
|
||||
|
||||
func (repo *TokenRepo) IsTokenValid(ctx context.Context, userID, tokenID string) (bool, error) {
|
||||
token, err := repo.TokenByID(ctx, userID, tokenID)
|
||||
token, err := repo.TokenByIDs(ctx, userID, tokenID)
|
||||
if err == nil {
|
||||
return token.Expiration.After(time.Now().UTC()), nil
|
||||
}
|
||||
@@ -33,8 +33,8 @@ func (repo *TokenRepo) IsTokenValid(ctx context.Context, userID, tokenID string)
|
||||
return false, err
|
||||
}
|
||||
|
||||
func (repo *TokenRepo) TokenByID(ctx context.Context, userID, tokenID string) (*usr_model.TokenView, error) {
|
||||
token, viewErr := repo.View.TokenByID(tokenID, authz.GetInstance(ctx).InstanceID())
|
||||
func (repo *TokenRepo) TokenByIDs(ctx context.Context, userID, tokenID string) (*usr_model.TokenView, error) {
|
||||
token, viewErr := repo.View.TokenByIDs(tokenID, userID, authz.GetInstance(ctx).InstanceID())
|
||||
if viewErr != nil && !errors.IsNotFound(viewErr) {
|
||||
return nil, viewErr
|
||||
}
|
||||
|
@@ -12,8 +12,8 @@ const (
|
||||
tokenTable = "auth.tokens"
|
||||
)
|
||||
|
||||
func (v *View) TokenByID(tokenID, instanceID string) (*model.TokenView, error) {
|
||||
return usr_view.TokenByID(v.Db, tokenTable, tokenID, instanceID)
|
||||
func (v *View) TokenByIDs(tokenID, userID, instanceID string) (*model.TokenView, error) {
|
||||
return usr_view.TokenByIDs(v.Db, tokenTable, tokenID, userID, instanceID)
|
||||
}
|
||||
|
||||
func (v *View) TokensByUserID(userID, instanceID string) ([]*model.TokenView, error) {
|
||||
|
@@ -8,5 +8,5 @@ import (
|
||||
|
||||
type TokenRepository interface {
|
||||
IsTokenValid(ctx context.Context, userID, tokenID string) (bool, error)
|
||||
TokenByID(ctx context.Context, userID, tokenID string) (*usr_model.TokenView, error)
|
||||
TokenByIDs(ctx context.Context, userID, tokenID string) (*usr_model.TokenView, error)
|
||||
}
|
||||
|
Reference in New Issue
Block a user