* secure Identity#email in case of missing auth_data_dump hash (#11936) * Refactor Identity#email * Delete wrongly commited debugging line * extract no email found message into Const * refactor Identity#email to use || as flow control
This commit is contained in:
parent
425c3072f7
commit
619dd813c7
1 changed files with 4 additions and 1 deletions
|
|
@ -1,4 +1,7 @@
|
|||
class Identity < ApplicationRecord
|
||||
NO_EMAIL_MSG = "No email found. Please relink your %<provider>s " \
|
||||
"account to avoid errors.".freeze
|
||||
|
||||
belongs_to :user
|
||||
|
||||
scope :enabled, -> { where(provider: Authentication::Providers.enabled) }
|
||||
|
|
@ -39,6 +42,6 @@ class Identity < ApplicationRecord
|
|||
end
|
||||
|
||||
def email
|
||||
auth_data_dump.info.email
|
||||
auth_data_dump&.info&.email || format(NO_EMAIL_MSG, provider: provider)
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue