Skip to content

Commit 3ebf4cc

Browse files
Prevent impersonation errors trying to use the current organization
1 parent 1d7d78d commit 3ebf4cc

2 files changed

Lines changed: 3 additions & 1 deletion

File tree

decidim-census/app/services/census_authorization_handler.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ class CensusAuthorizationHandler < Decidim::AuthorizationHandler
1919
attribute :date_of_birth, Date
2020
attribute :postal_code, String
2121
attribute :scope_id, Integer
22+
attribute :organization_id, Integer
2223

2324
def metadata
2425
{ birthdate: census_for_user&.birthdate&.strftime("%Y/%m/%d") }
@@ -55,7 +56,7 @@ def census_for_user
5556
end
5657

5758
def organization
58-
current_organization || user&.organization || scope&.organization
59+
current_organization || user&.organization || scope&.organization || Decidim::Organization.find_by(id: organization_id)
5960
end
6061

6162
# As we can get here from authorization validation or initiative signature

decidim-census/app/views/census_authorization/_form.html.erb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@
22
<%= form.text_field :id_document %>
33
<%= form.date_field :birthdate, min: 120.years.ago.to_date, max: Date.current, value: 35.years.ago.to_date %>
44
<%= form.hidden_field :handler_name %>
5+
<%= form.hidden_field :organization_id, value: current_organization.id %>
56
</div>

0 commit comments

Comments
 (0)