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

fix: confirmar usuaries en la invitación #13247
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful

This commit is contained in:
f 2023-04-24 17:44:04 -03:00
parent 5c467e08b8
commit 229914e849
4 changed files with 16 additions and 2 deletions

View file

@ -96,6 +96,12 @@ class UsuariesController < ApplicationController
# XXX: La invitación tiene que ser enviada luego de crear el rol
if role.persisted?
# Si es una cuenta manual que no está confirmada aun,
# aprovechar para reconfirmarla.
if !usuarie.confirmed? && !usuarie.created_by_invite?
usuarie.generate_confirmation_token!
end
usuarie.deliver_invitation
else
raise ArgumentError, role.errors.full_messages

View file

@ -51,9 +51,9 @@ class Usuarie < ApplicationRecord
end
# Les usuaries necesitan link de invitación si no tenían cuenta
# o todavía no la confirmaron
# y todavía no aceptaron la invitación anterior.
def needs_invitation_link?
(created_by_invite? && !invitation_accepted?) || !confirmed?
created_by_invite? && !invitation_accepted?
end
private

View file

@ -18,5 +18,9 @@
format: :'devise.mailer.invitation_instructions.accept_until_format'))
%p= t('devise.mailer.invitation_instructions.ignore')
- elsif !@resource.confirmed? && @resource.confirmation_token
= confirmation_url(@resource, confirmation_token: @token, change_locale_to: @resource.lang)
\
= t('devise.mailer.invitation_instructions.ignore')
- else
%p= link_to t('devise.mailer.invitation_instructions.sign_in'), root_url

View file

@ -18,6 +18,10 @@
format: :'devise.mailer.invitation_instructions.accept_until_format'))
\
= t('devise.mailer.invitation_instructions.ignore')
- elsif !@resource.confirmed? && @resource.confirmation_token
= confirmation_url(@resource, confirmation_token: @token, change_locale_to: @resource.lang)
\
= t('devise.mailer.invitation_instructions.ignore')
- else
= root_url(change_locale_to: @resource.lang)
= t('devise.mailer.invitation_instructions.sign_in')