From f6490fc1b8dc7ef9e46eb7c22c4a736315f1a6c8 Mon Sep 17 00:00:00 2001 From: Justin Coyne Date: Mon, 6 Nov 2023 10:45:54 -0600 Subject: [PATCH] Revert "Make the expiry time a property of the user model for ergonomics minting tokens" This reverts commit 5215abb4dee0f761dd0c387f6715c2e90730d5f9. The from_now method does not appear to be defined on Integer --- app/models/user.rb | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/app/models/user.rb b/app/models/user.rb index 4f7bf5c8..cd6c5e78 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -7,7 +7,6 @@ class User attr_accessor :id, :webauth_user, :anonymous_locatable_user, :app_user, :token_user, :ldap_groups, :ip_address, :jwt_tokens - attr_writer :expires_at, :expires_in def ability Ability.new(self) @@ -97,7 +96,7 @@ def self.from_token(token, additional_attributes = {}) return nil if expiry < Time.zone.now - User.new(attributes.merge(token_user: true, expires_at: expiry).merge(additional_attributes)) + User.new(attributes.merge(token_user: true).merge(additional_attributes)) end def token @@ -110,19 +109,11 @@ def token # mint time mint_time, # expiry time - expires_at + mint_time + Settings.token.default_expiry_time ] ) end - def expires_in - @expires_in || Settings.token.default_expiry_time - end - - def expires_at - @expires_at || expires_in.from_now - end - def self.encryptor salt = 'user' key = ActiveSupport::KeyGenerator.new(Rails.application.secrets.secret_key_base).generate_key(salt, 32)