Use collection partial for rule translation in signup flow (#35932)
This commit is contained in:
parent
a495a0cbfc
commit
14ca5d0e6b
@ -130,14 +130,19 @@ class Auth::RegistrationsController < Devise::RegistrationsController
|
|||||||
end
|
end
|
||||||
|
|
||||||
def require_rules_acceptance!
|
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
|
@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
|
render :rules
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def validated_accept_token?
|
||||||
|
session[:accept_token].present? && params[:accept] == session[:accept_token]
|
||||||
|
end
|
||||||
|
|
||||||
def is_flashing_format? # rubocop:disable Naming/PredicatePrefix
|
def is_flashing_format? # rubocop:disable Naming/PredicatePrefix
|
||||||
if params[:action] == 'create'
|
if params[:action] == 'create'
|
||||||
false # Disable flash messages for sign-up
|
false # Disable flash messages for sign-up
|
||||||
|
|||||||
@ -17,12 +17,7 @@
|
|||||||
%p.lead= t('auth.rules.preamble', domain: site_hostname)
|
%p.lead= t('auth.rules.preamble', domain: site_hostname)
|
||||||
|
|
||||||
%ol.rules-list
|
%ol.rules-list
|
||||||
- @rules.each do |rule|
|
= render collection: @rule_translations, partial: 'auth/rule_translations/rule_translation'
|
||||||
- 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
|
|
||||||
|
|
||||||
.stacked-actions
|
.stacked-actions
|
||||||
- accept_path = @invite_code.present? ? public_invite_url(invite_code: @invite_code, accept: @accept_token) : new_user_registration_path(accept: @accept_token)
|
- accept_path = @invite_code.present? ? public_invite_url(invite_code: @invite_code, accept: @accept_token) : new_user_registration_path(accept: @accept_token)
|
||||||
|
|||||||
@ -0,0 +1,4 @@
|
|||||||
|
%li
|
||||||
|
%button{ type: 'button', aria: { expanded: 'false' } }
|
||||||
|
.rules-list__text= rule_translation.text
|
||||||
|
.rules-list__hint= rule_translation.hint
|
||||||
Loading…
x
Reference in New Issue
Block a user