From c5faba9a6b4c1636fdc095e23cf02a4ec061ca9c Mon Sep 17 00:00:00 2001 From: f Date: Mon, 11 Jan 2021 13:22:11 -0300 Subject: [PATCH] =?UTF-8?q?al=20aceptar=20una=20invitaci=C3=B3n=20aceptar?= =?UTF-8?q?=20la=20invitaci=C3=B3n=20al=20sitio=20tambi=C3=A9n?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/usuaries_controller.rb | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/app/controllers/usuaries_controller.rb b/app/controllers/usuaries_controller.rb index ea35f161..edcd7d68 100644 --- a/app/controllers/usuaries_controller.rb +++ b/app/controllers/usuaries_controller.rb @@ -104,16 +104,21 @@ class UsuariesController < ApplicationController # Aceptar la invitación def accept_invitation @site = find_site + rol = current_usuarie.rol_for_site(@site) # Le usuarie ya aceptó la invitación - unless current_usuarie.rol_for_site(@site)&.temporal + unless rol&.temporal redirect_to sites_path return end authorize SiteUsuarie.new(@site, current_usuarie) - @site.touch if current_usuarie.rol_for_site(@site).update_attribute :temporal, false + Rol.transaction do + rol.update(temporal: false) && + current_usuaria.update(invitation_token: nil) && + @site.touch + end redirect_to sites_path end