diff --git a/app/controllers/auth/registrations_controller.rb b/app/controllers/auth/registrations_controller.rb index b8c21f3ccd7..b315b273d58 100644 --- a/app/controllers/auth/registrations_controller.rb +++ b/app/controllers/auth/registrations_controller.rb @@ -130,14 +130,19 @@ class Auth::RegistrationsController < Devise::RegistrationsController end def require_rules_acceptance! - return if @rules.empty? || (session[:accept_token].present? && params[:accept] == session[:accept_token]) + return if @rules.empty? || validated_accept_token? @accept_token = session[:accept_token] = SecureRandom.hex - @invite_code = invite_code + @invite_code = invite_code + @rule_translations = @rules.map { |rule| rule.translation_for(I18n.locale) } render :rules end + def validated_accept_token? + session[:accept_token].present? && params[:accept] == session[:accept_token] + end + def is_flashing_format? # rubocop:disable Naming/PredicatePrefix if params[:action] == 'create' false # Disable flash messages for sign-up diff --git a/app/views/auth/registrations/rules.html.haml b/app/views/auth/registrations/rules.html.haml index a5a96c57378..1e3d934c375 100644 --- a/app/views/auth/registrations/rules.html.haml +++ b/app/views/auth/registrations/rules.html.haml @@ -17,12 +17,7 @@ %p.lead= t('auth.rules.preamble', domain: site_hostname) %ol.rules-list - - @rules.each do |rule| - - translation = rule.translation_for(I18n.locale.to_s) - %li - %button{ type: 'button', aria: { expanded: 'false' } } - .rules-list__text= translation.text - .rules-list__hint= translation.hint + = render collection: @rule_translations, partial: 'auth/rule_translations/rule_translation' .stacked-actions - accept_path = @invite_code.present? ? public_invite_url(invite_code: @invite_code, accept: @accept_token) : new_user_registration_path(accept: @accept_token) diff --git a/app/views/auth/rule_translations/_rule_translation.html.haml b/app/views/auth/rule_translations/_rule_translation.html.haml new file mode 100644 index 00000000000..32b9cc28af1 --- /dev/null +++ b/app/views/auth/rule_translations/_rule_translation.html.haml @@ -0,0 +1,4 @@ +%li + %button{ type: 'button', aria: { expanded: 'false' } } + .rules-list__text= rule_translation.text + .rules-list__hint= rule_translation.hint