Use built-in authenticate_or_request_with_http_token

Hat tip to @adrienpoly
This commit is contained in:
David Heinemeier Hansson
2025-12-03 10:39:47 +01:00
committed by Stanko K.R.
parent d82093c0cd
commit 79fc57a82a
2 changed files with 7 additions and 11 deletions
+4 -2
View File
@@ -14,8 +14,10 @@ class Identity < ApplicationRecord
validates :email_address, format: { with: URI::MailTo::EMAIL_REGEXP }
normalizes :email_address, with: ->(value) { value.strip.downcase.presence }
def self.find_by_access_token(token)
AccessToken.find_by(token: token)&.identity
def self.find_by_permissable_access_token(token, method:)
if (access_token = AccessToken.find_by(token: token)) && access_token.allows?(method)
access_token.identity
end
end
def send_magic_link(**attributes)