5
0
Fork 0
mirror of https://0xacab.org/sutty/sutty synced 2024-11-29 16:16:22 +00:00

Merge branch 'issue-2123' into panel.sutty.nl
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful

This commit is contained in:
f 2023-03-23 11:49:58 -03:00
commit af53d59e53
3 changed files with 12 additions and 7 deletions

View file

@ -83,16 +83,19 @@ class UsuariesController < ApplicationController
# Enviar la invitación si es necesario y agregar al sitio # Enviar la invitación si es necesario y agregar al sitio
invitaciones.each do |invitacion| invitaciones.each do |invitacion|
attributes = { email: invitacion.address } attributes = { email: invitacion.address }
options = { skip_invitation: true }
next if Usuarie.where(id: @site.roles.pluck(:usuarie_id)).find_by(attributes) next if Usuarie.where(id: @site.roles.pluck(:usuarie_id)).find_by(attributes)
usuarie = Usuarie.find_by attributes.tap do |u| usuarie = Usuarie.find_by attributes
u.send_devise_notification(:invitation_instructions, nil) usuarie ||= Usuarie.invite!(attributes, nil, options).tap do |u|
u.generate_invitation_token!
end end
usuarie ||= Usuarie.invite! attributes
@site.roles.create(usuarie: usuarie, temporal: true, rol: invited_as) @site.roles.create(usuarie: usuarie, temporal: true, rol: invited_as)
# XXX: La invitación tiene que ser enviada luego de crear el rol
usuarie.send(:send_devise_notification, :invitation_instructions, nil)
end end
redirect_to site_usuaries_path(@site) redirect_to site_usuaries_path(@site)

View file

@ -19,4 +19,6 @@
- else - else
%p= link_to t('devise.mailer.invitation_instructions.sign_in'), root_url(change_locale_to: @resource.lang) %p= link_to t('devise.mailer.invitation_instructions.sign_in'), root_url(change_locale_to: @resource.lang)
%p= t('devise.mailer.invitation_instructions.ignore') %p= t('devise.mailer.invitation_instructions.ignore')
- else
%p= link_to t('devise.mailer.invitation_instructions.sign_in'), root_url

View file

@ -16,8 +16,8 @@
= t('devise.mailer.invitation_instructions.accept_until', = t('devise.mailer.invitation_instructions.accept_until',
due_date: l(@resource.invitation_due_at, due_date: l(@resource.invitation_due_at,
format: :'devise.mailer.invitation_instructions.accept_until_format')) format: :'devise.mailer.invitation_instructions.accept_until_format'))
\
= t('devise.mailer.invitation_instructions.ignore')
- else - else
= root_url(change_locale_to: @resource.lang) = root_url(change_locale_to: @resource.lang)
= t('devise.mailer.invitation_instructions.sign_in') = t('devise.mailer.invitation_instructions.sign_in')
\
= t('devise.mailer.invitation_instructions.ignore')