mirror of
https://github.com/rickbarrette/redmine_qbo.git
synced 2026-04-02 08:21:57 -04:00
Added comments
This commit is contained in:
@@ -21,14 +21,17 @@ class CustomerToken < ApplicationRecord
|
|||||||
|
|
||||||
TOKEN_EXPIRATION = 1.month
|
TOKEN_EXPIRATION = 1.month
|
||||||
|
|
||||||
|
# Check if the token has expired
|
||||||
def expired?
|
def expired?
|
||||||
expires_at.present? && expires_at <= Time.current
|
expires_at.present? && expires_at <= Time.current
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Remove expired tokens from the database
|
||||||
def self.remove_expired_tokens
|
def self.remove_expired_tokens
|
||||||
where("expires_at <= ?", Time.current).delete_all
|
where("expires_at <= ?", Time.current).delete_all
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Get or create a token for the given issue
|
||||||
def self.get_token(issue)
|
def self.get_token(issue)
|
||||||
return unless issue
|
return unless issue
|
||||||
return unless User.current.allowed_to?(:view_issues, issue.project)
|
return unless User.current.allowed_to?(:view_issues, issue.project)
|
||||||
@@ -41,10 +44,12 @@ class CustomerToken < ApplicationRecord
|
|||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
|
# Generate a unique token for the customer
|
||||||
def generate_token
|
def generate_token
|
||||||
self.token ||= SecureRandom.urlsafe_base64(32)
|
self.token ||= SecureRandom.urlsafe_base64(32)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Generate an expiration date for the token
|
||||||
def generate_expire_date
|
def generate_expire_date
|
||||||
self.expires_at ||= Time.current + TOKEN_EXPIRATION
|
self.expires_at ||= Time.current + TOKEN_EXPIRATION
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user