5
0
Fork 0
mirror of https://0xacab.org/sutty/sutty synced 2024-11-15 08:11:41 +00:00

fix: aceptar la invitación al confirmar la cuenta #13247
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful

This commit is contained in:
f 2023-04-24 17:03:38 -03:00
parent 29f4c7a847
commit 1cf5ca5953

View file

@ -12,6 +12,7 @@ class Usuarie < ApplicationRecord
validates_with EmailAddress::ActiveRecordValidator, field: :email validates_with EmailAddress::ActiveRecordValidator, field: :email
before_create :lang_from_locale! before_create :lang_from_locale!
before_update :accept_invitation_after_confirmation!
has_many :roles has_many :roles
has_many :sites, through: :roles has_many :sites, through: :roles
@ -54,4 +55,13 @@ class Usuarie < ApplicationRecord
def lang_from_locale! def lang_from_locale!
self.lang = I18n.locale.to_s self.lang = I18n.locale.to_s
end end
# Si le usuarie (re)confirma su cuenta con una invitación pendiente,
# considerarla aceptada también.
def accept_invitation_after_confirmation!
if confirmed?
self.invitation_token = nil
self.invitation_accepted_at ||= Time.now.utc
end
end
end end