diff --git a/pkg/internal/services/cleaner.go b/pkg/internal/services/cleaner.go index d124f3e..2a33319 100644 --- a/pkg/internal/services/cleaner.go +++ b/pkg/internal/services/cleaner.go @@ -3,18 +3,16 @@ package services import ( "git.solsynth.dev/hydrogen/passport/pkg/internal/database" "github.com/rs/zerolog/log" - "time" ) func DoAutoDatabaseCleanup() { - deadline := time.Now().Add(60 * time.Minute) - log.Debug().Time("deadline", deadline).Msg("Now cleaning up entire database...") + log.Debug().Msg("Now cleaning up entire database...") var count int64 for _, model := range database.AutoMaintainRange { - tx := database.C.Unscoped().Delete(model, "deleted_at >= ?", deadline) + tx := database.C.Unscoped().Delete(model, "deleted_at IS NOT NULL") if tx.Error != nil { - log.Error().Err(tx.Error).Msg("An error occurred when running auth context cleanup...") + log.Error().Err(tx.Error).Msg("An error occurred when running cleaning up entire database...") } count += tx.RowsAffected } diff --git a/pkg/internal/services/ticker_maintainer.go b/pkg/internal/services/ticker_maintainer.go index 78fdcf7..c44ae45 100644 --- a/pkg/internal/services/ticker_maintainer.go +++ b/pkg/internal/services/ticker_maintainer.go @@ -1,21 +1,21 @@ package services import ( + "time" + "git.solsynth.dev/hydrogen/passport/pkg/internal/database" "git.solsynth.dev/hydrogen/passport/pkg/internal/models" "github.com/rs/zerolog/log" - "github.com/spf13/viper" - "time" ) func DoAutoSignoff() { - duration := time.Duration(viper.GetInt64("security.auto_signoff_duration")) * time.Second - divider := time.Now().Add(-duration) + duration := 7 * 24 * time.Hour + deadline := time.Now().Add(-duration) - log.Debug().Time("before", divider).Msg("Now signing off tickets...") + log.Debug().Time("before", deadline).Msg("Now signing off tickets...") if tx := database.C. - Where("last_grant_at < ?", divider). + Where("last_grant_at < ?", deadline). Delete(&models.AuthTicket{}); tx.Error != nil { log.Error().Err(tx.Error).Msg("An error occurred when running auto sign off...") } else { diff --git a/settings.toml b/settings.toml index 945ad7e..5fc0b4f 100644 --- a/settings.toml +++ b/settings.toml @@ -35,7 +35,6 @@ password = "gz937Zxxzfcd9SeH" [security] cookie_domain = "localhost" cookie_samesite = "Lax" -auto_signoff_duration = 86400 access_token_duration = 300 refresh_token_duration = 2592000