add access tokens

This commit is contained in:
Alex Turchyn
2023-08-06 17:33:08 +03:00
parent e75e7b18b4
commit 6d78d5430c
7 changed files with 76 additions and 8 deletions
+5
View File
@@ -45,6 +45,7 @@ class User < ApplicationRecord
EMAIL_REGEXP = /[^@,\s]+@[^@,\s]+/
belongs_to :account
has_one :access_token, dependent: :destroy
devise :database_authenticatable, :recoverable, :rememberable, :validatable, :trackable
devise :registerable, :omniauthable, omniauth_providers: [:google_oauth2] if Docuseal.multitenant?
@@ -54,6 +55,10 @@ class User < ApplicationRecord
scope :active, -> { where(deleted_at: nil) }
def access_token
super || build_access_token.tap(&:save!)
end
def active_for_authentication?
!deleted_at?
end