mirror of
https://github.com/zitadel/zitadel.git
synced 2024-12-12 02:54:20 +00:00
fix: ensure no events are skipped on token check (#6663)
fix: ensure no events are skipped on token check
This commit is contained in:
parent
15fd3045e0
commit
e3ac217424
@ -45,16 +45,19 @@ func (repo *TokenVerifierRepo) tokenByID(ctx context.Context, tokenID, userID st
|
|||||||
defer func() { span.EndWithError(err) }()
|
defer func() { span.EndWithError(err) }()
|
||||||
|
|
||||||
instanceID := authz.GetInstance(ctx).InstanceID()
|
instanceID := authz.GetInstance(ctx).InstanceID()
|
||||||
|
|
||||||
|
// always load the latest sequence first, so in case the token was not found by id,
|
||||||
|
// the sequence will be equal or lower than the actual projection and no events are lost
|
||||||
|
sequence, err := repo.View.GetLatestTokenSequence(ctx, instanceID)
|
||||||
|
logging.WithFields("instanceID", instanceID, "userID", userID, "tokenID", tokenID).
|
||||||
|
OnError(err).
|
||||||
|
Errorf("could not get current sequence for token check")
|
||||||
|
|
||||||
token, viewErr := repo.View.TokenByIDs(tokenID, userID, instanceID)
|
token, viewErr := repo.View.TokenByIDs(tokenID, userID, instanceID)
|
||||||
if viewErr != nil && !caos_errs.IsNotFound(viewErr) {
|
if viewErr != nil && !caos_errs.IsNotFound(viewErr) {
|
||||||
return nil, viewErr
|
return nil, viewErr
|
||||||
}
|
}
|
||||||
if caos_errs.IsNotFound(viewErr) {
|
if caos_errs.IsNotFound(viewErr) {
|
||||||
sequence, err := repo.View.GetLatestTokenSequence(ctx, instanceID)
|
|
||||||
logging.WithFields("instanceID", instanceID, "userID", userID, "tokenID", tokenID).
|
|
||||||
OnError(err).
|
|
||||||
Errorf("could not get current sequence for token check")
|
|
||||||
|
|
||||||
token = new(model.TokenView)
|
token = new(model.TokenView)
|
||||||
token.ID = tokenID
|
token.ID = tokenID
|
||||||
token.UserID = userID
|
token.UserID = userID
|
||||||
|
Loading…
Reference in New Issue
Block a user