Skip to content

Commit

Permalink
fix(api): authentication consumer migration (#5850)
Browse files Browse the repository at this point in the history
Signed-off-by: francois  samin <[email protected]>
  • Loading branch information
fsamin authored Jun 16, 2021
1 parent 2581044 commit 09c1cf0
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions engine/api/migrate/migrate_auth_consumer_token_expiration.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ func AuthConsumerTokenExpiration(ctx context.Context, dbFunc func() *gorp.DbMap,

func authConsumerTokenExpirationPerID(ctx context.Context, tx gorpmapper.SqlExecutorWithTx, id string, duration time.Duration) error {
// Lock the row
id, err := tx.SelectStr("select id from auth_consumer where id=$1 and validity_periods is null for update skip locked")
id, err := tx.SelectStr("select id from auth_consumer where id=$1 and validity_periods is null for update skip locked", id)
if err == sql.ErrNoRows {
return nil
}
Expand All @@ -70,7 +70,7 @@ func authConsumerTokenExpirationPerID(ctx context.Context, tx gorpmapper.SqlExec
return nil
}

consumer.ValidityPeriods = sdk.NewAuthConsumerValidityPeriod(time.Now(), duration)
consumer.ValidityPeriods = sdk.NewAuthConsumerValidityPeriod(consumer.DeprecatedIssuedAt, duration)
log.Info(ctx, "consumer %q IAT=%v Expiration=%v", consumer.ID, consumer.ValidityPeriods.Latest().IssuedAt, consumer.ValidityPeriods.Latest().IssuedAt.Add(consumer.ValidityPeriods.Latest().Duration))

return authentication.UpdateConsumer(ctx, tx, consumer)
Expand Down

0 comments on commit 09c1cf0

Please sign in to comment.