Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "Make the expiry time a property of the user model for ergonom… #1015

Merged
merged 1 commit into from
Nov 6, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 2 additions & 11 deletions app/models/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand All @@ -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)
Expand Down