From 1cf5ca5953da4f54f18b2951a2781b325f77d05c Mon Sep 17 00:00:00 2001 From: f Date: Mon, 24 Apr 2023 17:03:38 -0300 Subject: [PATCH] =?UTF-8?q?fix:=20aceptar=20la=20invitaci=C3=B3n=20al=20co?= =?UTF-8?q?nfirmar=20la=20cuenta=20#13247?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/usuarie.rb | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/app/models/usuarie.rb b/app/models/usuarie.rb index 9b9fd4e6..0dcf917d 100644 --- a/app/models/usuarie.rb +++ b/app/models/usuarie.rb @@ -12,6 +12,7 @@ class Usuarie < ApplicationRecord validates_with EmailAddress::ActiveRecordValidator, field: :email before_create :lang_from_locale! + before_update :accept_invitation_after_confirmation! has_many :roles has_many :sites, through: :roles @@ -54,4 +55,13 @@ class Usuarie < ApplicationRecord def lang_from_locale! self.lang = I18n.locale.to_s 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