Fantasy-Fit / fantasy-fit-web

Creative Commons Zero v1.0 Universal
3 stars 2 forks source link

Create background job to cleanup BlacklistedTokens #134

Closed chris-t-li closed 1 year ago

chris-t-li commented 1 year ago

Currently, on user logout, a BlacklistedToken is created so that subsequence use of the token will be rejected by authentication.

However, there is no cleanup process that destroys expired tokens.

Need to create a background task that will run [daily] that will destroy expired tokens Screen Shot 2023-05-10 at 11 03 13 AM

alexistorosina1 commented 1 year ago

this must mean that some expired tokens arent being deleted. I believe there is a background task is being ran everyday at 4:30am

chris-t-li commented 1 year ago

Maybe is here, in models/blacklisted_token.rb

Should it be "destroy_all" instead of "delete_all"? .

class BlacklistedToken < ApplicationRecord
    belongs_to :user

    def self.delete_expired_tokens
        self.where("expires_at < ?", Time.current).delete_all
    end
end
alexistorosina1 commented 1 year ago

will check it out