mirror of
1
Fork 0

Fix token sweep (#19)

* fix token sweep not working
* change sweep message to trace
This commit is contained in:
Tobi Smethurst 2021-05-09 14:28:43 +02:00 committed by GitHub
parent 3363e0ebdd
commit 41915ab371
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 2 deletions

View File

@ -56,7 +56,7 @@ func newTokenStore(ctx context.Context, db db.DB, log *logrus.Logger) oauth2.Tok
log.Info("breaking cleanloop") log.Info("breaking cleanloop")
break cleanloop break cleanloop
case <-time.After(1 * time.Minute): case <-time.After(1 * time.Minute):
log.Debug("sweeping out old oauth entries broom broom") log.Trace("sweeping out old oauth entries broom broom")
if err := pts.sweep(); err != nil { if err := pts.sweep(); err != nil {
log.Errorf("error while sweeping oauth entries: %s", err) log.Errorf("error while sweeping oauth entries: %s", err)
} }
@ -82,7 +82,7 @@ func (pts *tokenStore) sweep() error {
// we only want to check if a token expired before now if the expiry time is *not zero*; // we only want to check if a token expired before now if the expiry time is *not zero*;
// ie., if it's been explicity set. // ie., if it's been explicity set.
if !pgt.CodeExpiresAt.IsZero() && pgt.CodeExpiresAt.Before(now) || !pgt.RefreshExpiresAt.IsZero() && pgt.RefreshExpiresAt.Before(now) || !pgt.AccessExpiresAt.IsZero() && pgt.AccessExpiresAt.Before(now) { if !pgt.CodeExpiresAt.IsZero() && pgt.CodeExpiresAt.Before(now) || !pgt.RefreshExpiresAt.IsZero() && pgt.RefreshExpiresAt.Before(now) || !pgt.AccessExpiresAt.IsZero() && pgt.AccessExpiresAt.Before(now) {
if err := pts.db.DeleteByID(pgt.ID, &pgt); err != nil { if err := pts.db.DeleteByID(pgt.ID, pgt); err != nil {
return err return err
} }
} }