decidim-core 0.32.1 → 0.32.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/app/cells/decidim/address_cell.rb +7 -3
- data/app/cells/decidim/card_metadata_cell.rb +3 -1
- data/app/cells/decidim/content_blocks/participatory_space_main_data/title.erb +1 -14
- data/app/cells/decidim/date_range/show.erb +6 -6
- data/app/cells/decidim/date_range_cell.rb +7 -2
- data/app/cells/decidim/following_cell.rb +1 -1
- data/app/cells/decidim/member/show.erb +1 -1
- data/app/cells/decidim/nav_links/show.erb +3 -1
- data/app/cells/decidim/share_text_widget/modal.erb +1 -0
- data/app/cells/decidim/share_widget/modal.erb +1 -0
- data/app/cells/decidim/share_widget/qr_code_modal.erb +2 -4
- data/app/commands/decidim/create_follow.rb +2 -3
- data/app/commands/decidim/create_omniauth_registration.rb +19 -7
- data/app/commands/decidim/create_user_report.rb +1 -1
- data/app/commands/decidim/destroy_account.rb +6 -6
- data/app/commands/decidim/destroy_ephemeral_user.rb +2 -0
- data/app/commands/decidim/invite_user.rb +1 -1
- data/app/commands/decidim/multiple_attachments_methods.rb +17 -3
- data/app/commands/decidim/update_resources_taxonomies.rb +2 -1
- data/app/controllers/concerns/decidim/devise_authentication_methods.rb +4 -0
- data/app/controllers/concerns/decidim/devise_controllers.rb +2 -0
- data/app/controllers/concerns/decidim/direct_upload.rb +12 -6
- data/app/controllers/concerns/decidim/disable_redirection_to_external_host.rb +2 -0
- data/app/controllers/concerns/decidim/filter_resource.rb +2 -0
- data/app/controllers/concerns/decidim/impersonate_users.rb +4 -4
- data/app/controllers/concerns/decidim/locale_switcher.rb +12 -10
- data/app/controllers/concerns/decidim/needs_organization.rb +15 -0
- data/app/controllers/concerns/decidim/needs_permission.rb +22 -10
- data/app/controllers/concerns/decidim/onboarding_action_methods.rb +2 -0
- data/app/controllers/concerns/decidim/paginable.rb +7 -3
- data/app/controllers/concerns/decidim/payload_info.rb +2 -0
- data/app/controllers/concerns/decidim/resource_versions_concern.rb +14 -0
- data/app/controllers/decidim/amendments_controller.rb +34 -6
- data/app/controllers/decidim/application_controller.rb +2 -6
- data/app/controllers/decidim/authorization_modals_controller.rb +3 -1
- data/app/controllers/decidim/components/base_controller.rb +2 -0
- data/app/controllers/decidim/devise/passwords_controller.rb +8 -0
- data/app/controllers/decidim/doorkeeper/authorizations_controller.rb +10 -4
- data/app/controllers/decidim/doorkeeper/credentials_controller.rb +6 -1
- data/app/controllers/decidim/favicon_controller.rb +9 -0
- data/app/controllers/decidim/free_resource_authorization_modals_controller.rb +2 -0
- data/app/controllers/decidim/gamification/badges_controller.rb +2 -0
- data/app/controllers/decidim/homepage_controller.rb +4 -1
- data/app/controllers/decidim/likes_controller.rb +1 -1
- data/app/controllers/decidim/links_controller.rb +2 -0
- data/app/controllers/decidim/manifests_controller.rb +2 -0
- data/app/controllers/decidim/messaging/conversations_controller.rb +11 -5
- data/app/controllers/decidim/newsletters_controller.rb +4 -0
- data/app/controllers/decidim/notifications_subscriptions_controller.rb +4 -0
- data/app/controllers/decidim/offline_controller.rb +5 -1
- data/app/controllers/decidim/open_data_controller.rb +5 -1
- data/app/controllers/decidim/pages_controller.rb +31 -3
- data/app/controllers/decidim/private_downloads_controller.rb +2 -0
- data/app/controllers/decidim/profiles_controller.rb +20 -2
- data/app/controllers/decidim/qr_controller.rb +3 -1
- data/app/controllers/decidim/resource_autocomplete_controller.rb +2 -0
- data/app/controllers/decidim/searches_controller.rb +2 -0
- data/app/controllers/decidim/short_links_controller.rb +4 -0
- data/app/controllers/decidim/static_map_controller.rb +2 -0
- data/app/controllers/decidim/timeouts_controller.rb +4 -0
- data/app/controllers/decidim/tos_controller.rb +2 -0
- data/app/controllers/decidim/upload_validations_controller.rb +4 -2
- data/app/controllers/decidim/user_activities_controller.rb +3 -0
- data/app/forms/decidim/upload_validation_form.rb +16 -10
- data/app/helpers/concerns/decidim/user_role_checker.rb +35 -10
- data/app/helpers/decidim/cells_paginate_helper.rb +0 -5
- data/app/helpers/decidim/decidim_form_helper.rb +1 -1
- data/app/helpers/decidim/layout_helper.rb +1 -0
- data/app/helpers/decidim/orders_helper.rb +8 -6
- data/app/helpers/decidim/paginate_helper.rb +15 -3
- data/app/helpers/decidim/sanitize_helper.rb +11 -1
- data/app/helpers/decidim/url_helper.rb +35 -0
- data/app/jobs/decidim/application_job.rb +4 -0
- data/app/jobs/decidim/open_data_job.rb +21 -5
- data/app/models/decidim/action_log.rb +7 -1
- data/app/models/decidim/authorization.rb +24 -0
- data/app/models/decidim/component.rb +10 -0
- data/app/models/decidim/like.rb +1 -1
- data/app/models/decidim/oauth_application.rb +1 -0
- data/app/models/decidim/user.rb +1 -0
- data/app/models/decidim/user_base_entity.rb +1 -1
- data/app/packs/src/decidim/callout.js +10 -0
- data/app/packs/src/decidim/callout.test.js +32 -0
- data/app/packs/src/decidim/controllers/accordion/accordion.test.js +64 -0
- data/app/packs/src/decidim/controllers/accordion/controller.js +43 -0
- data/app/packs/src/decidim/controllers/autofocus/controller.js +30 -0
- data/app/packs/src/decidim/controllers/language_change/controller.js +21 -8
- data/app/packs/src/decidim/controllers/language_change/language_change.test.js +0 -1
- data/app/packs/src/decidim/controllers/mention/controller.js +32 -3
- data/app/packs/src/decidim/controllers/mention/input_mentions.test.js +8 -5
- data/app/packs/src/decidim/controllers/multiple_mentions/input_multiple_mentions.test.js +1 -1
- data/app/packs/src/decidim/datepicker/datepicker_functions.js +61 -32
- data/app/packs/src/decidim/datepicker/form_datepicker.js +18 -2
- data/app/packs/src/decidim/datepicker/generate_datepicker.js +16 -8
- data/app/packs/src/decidim/datepicker/generate_timepicker.js +5 -3
- data/app/packs/src/decidim/datepicker/test/date.test.js +8 -0
- data/app/packs/src/decidim/datepicker/test/datepicker_functions_adjust_picker_position.test.js +64 -0
- data/app/packs/src/decidim/datepicker/test/time.test.js +39 -24
- data/app/packs/src/decidim/editor/common/suggestion.js +32 -22
- data/app/packs/src/decidim/editor/extensions/mention/index.js +14 -3
- data/app/packs/src/decidim/editor/index.js +4 -0
- data/app/packs/src/decidim/editor/test/extensions/mention.test.js +32 -9
- data/app/packs/src/decidim/refactor/implementation/autofocus.js +22 -0
- data/app/packs/src/decidim/refactor/implementation/autofocus.test.js +171 -0
- data/app/packs/src/decidim/utilities/dom.js +2 -2
- data/app/packs/stylesheets/decidim/_content_blocks.scss +4 -10
- data/app/packs/stylesheets/decidim/_conversations.scss +0 -8
- data/app/packs/stylesheets/decidim/_datepicker.scss +3 -3
- data/app/packs/stylesheets/decidim/_modal.scss +16 -8
- data/app/packs/stylesheets/decidim/_modal_share.scss +0 -22
- data/app/packs/stylesheets/decidim/_participatory_spaces.scss +11 -1
- data/app/packs/stylesheets/decidim/_rich_text.scss +12 -9
- data/app/packs/stylesheets/decidim/_spinner.scss +16 -0
- data/app/packs/stylesheets/decidim/_tom_select.scss +1 -1
- data/app/packs/stylesheets/decidim/_typography.scss +5 -2
- data/app/packs/stylesheets/decidim/application.scss +1 -0
- data/app/packs/stylesheets/decidim/legacy/email.scss +0 -5
- data/app/permissions/decidim/permissions.rb +20 -0
- data/app/presenters/decidim/admin_log/component_presenter.rb +1 -1
- data/app/presenters/decidim/log/base_presenter.rb +20 -2
- data/app/presenters/decidim/log/user_presenter.rb +2 -2
- data/app/presenters/decidim/menu_item_presenter.rb +1 -5
- data/app/presenters/decidim/resource_presenter.rb +11 -0
- data/app/resolvers/decidim/meta_image_url_resolver.rb +7 -1
- data/app/serializers/decidim/exporters/open_data_blocked_user_serializer.rb +11 -2
- data/app/serializers/decidim/exporters/open_data_moderation_serializer.rb +25 -1
- data/app/services/decidim/action_logger.rb +97 -29
- data/app/services/decidim/svg_content_validator.rb +889 -0
- data/app/uploaders/decidim/application_uploader.rb +2 -2
- data/app/validators/uploader_image_content_validator.rb +280 -0
- data/app/views/decidim/application/_radio_accordion.html.erb +1 -5
- data/app/views/decidim/manifests/show.json.erb +25 -22
- data/app/views/decidim/messaging/conversations/_add_conversation_users.html.erb +1 -1
- data/app/views/decidim/messaging/conversations/create.js.erb +1 -3
- data/app/views/decidim/shared/_login_modal.html.erb +12 -14
- data/app/views/decidim/shared/_results_per_page.html.erb +1 -1
- data/app/views/layouts/decidim/_mailer_logo.html.erb +1 -1
- data/app/views/layouts/decidim/header/_menu_breadcrumb_desktop.html.erb +3 -2
- data/config/initializers/rack_attack.rb +10 -0
- data/config/locales/bg.yml +1 -4
- data/config/locales/ca-IT.yml +10 -4
- data/config/locales/ca.yml +17 -11
- data/config/locales/cs.yml +24 -4
- data/config/locales/de.yml +100 -6
- data/config/locales/en.yml +10 -4
- data/config/locales/es-MX.yml +10 -4
- data/config/locales/es-PY.yml +10 -4
- data/config/locales/es.yml +16 -10
- data/config/locales/eu.yml +171 -168
- data/config/locales/fi-plain.yml +5 -3
- data/config/locales/fi.yml +5 -3
- data/config/locales/fr-CA.yml +10 -4
- data/config/locales/fr.yml +10 -4
- data/config/locales/gl.yml +1484 -33
- data/config/locales/hu.yml +0 -1
- data/config/locales/it.yml +0 -2
- data/config/locales/ja.yml +6 -4
- data/config/locales/pl.yml +1 -4
- data/config/locales/pt-BR.yml +1 -4
- data/config/locales/ro-RO.yml +0 -3
- data/config/locales/sk.yml +70 -4
- data/config/locales/sv.yml +71 -15
- data/config/locales/tr-TR.yml +1 -3
- data/config/routes.rb +11 -2
- data/db/migrate/20250523104311_move_cta_to_hero_content_block.rb +1 -1
- data/db/migrate/20250527122040_move_highlighted_content_banner_settings_to_content_block.rb +3 -0
- data/db/migrate/20260909000000_add_failed_attempts_and_locked_at_to_decidim_authorizations.rb +8 -0
- data/db/migrate/20261007090000_make_user_optional_in_action_logs.rb +12 -0
- data/decidim-core.gemspec +1 -1
- data/lib/decidim/api/functions/user_entity_list.rb +1 -0
- data/lib/decidim/api/types/user_moderation_type.rb +2 -2
- data/lib/decidim/content_parsers/user_parser.rb +1 -1
- data/lib/decidim/content_parsers.rb +0 -1
- data/lib/decidim/content_renderers/mention_resource_renderer.rb +19 -5
- data/lib/decidim/content_renderers/user_renderer.rb +15 -4
- data/lib/decidim/core/test/shared_examples/participatory_space_members_page_examples.rb +77 -0
- data/lib/decidim/core/test/shared_examples/participatory_space_members_shared_examples.rb +58 -0
- data/lib/decidim/core/test/shared_examples/versions_controller_examples.rb +23 -1
- data/lib/decidim/core/version.rb +1 -1
- data/lib/decidim/core.rb +10 -1
- data/lib/decidim/form_builder.rb +9 -1
- data/lib/decidim/has_upload_validations.rb +1 -0
- data/lib/decidim/legacy_form_builder.rb +4 -0
- data/lib/decidim/maintenance/import_models/scope.rb +2 -1
- data/lib/decidim/maintenance/taxonomy_importer.rb +4 -1
- data/lib/decidim/seeds.rb +1 -1
- data/lib/decidim/view_model.rb +1 -0
- data/lib/tasks/decidim_open_data_tasks.rake +7 -0
- metadata +14 -7
- data/lib/decidim/content_parsers/inline_images_parser.rb +0 -68
- data/lib/tasks/upgrade/decidim_active_storage_migration_tasks.rake +0 -79
|
@@ -13,9 +13,7 @@ module Decidim
|
|
|
13
13
|
helper_method :per_page, :page_offset
|
|
14
14
|
helper Decidim::PaginateHelper
|
|
15
15
|
|
|
16
|
-
|
|
17
|
-
resources.page(params[:page]).per(per_page)
|
|
18
|
-
end
|
|
16
|
+
protected
|
|
19
17
|
|
|
20
18
|
def per_page
|
|
21
19
|
if OPTIONS.include?(params[:per_page])
|
|
@@ -31,6 +29,12 @@ module Decidim
|
|
|
31
29
|
def page_offset
|
|
32
30
|
[params[:page].to_i - 1, 0].max * per_page
|
|
33
31
|
end
|
|
32
|
+
|
|
33
|
+
private
|
|
34
|
+
|
|
35
|
+
def paginate(resources)
|
|
36
|
+
resources.page(params[:page]).per(per_page)
|
|
37
|
+
end
|
|
34
38
|
end
|
|
35
39
|
end
|
|
36
40
|
end
|
|
@@ -11,11 +11,25 @@ module Decidim
|
|
|
11
11
|
helper_method :current_version, :versioned_resource
|
|
12
12
|
|
|
13
13
|
def show
|
|
14
|
+
enforce_permission_to(*versioned_resource_permission)
|
|
15
|
+
|
|
14
16
|
raise ActionController::RoutingError, "Not found" unless current_version
|
|
15
17
|
end
|
|
16
18
|
|
|
17
19
|
private
|
|
18
20
|
|
|
21
|
+
# The versions must honour the same `:read` permission as their resource,
|
|
22
|
+
# so a resource that is hidden, private, deleted or unpublished (and
|
|
23
|
+
# therefore cannot be read on its own) cannot be reached through its
|
|
24
|
+
# versions either.
|
|
25
|
+
def versioned_resource_permission
|
|
26
|
+
resource = versioned_resource
|
|
27
|
+
raise ActionController::RoutingError, "Not found" unless resource
|
|
28
|
+
|
|
29
|
+
subject = resource.model_name.element.to_sym
|
|
30
|
+
[:read, subject, { subject => resource }]
|
|
31
|
+
end
|
|
32
|
+
|
|
19
33
|
# Overwrite this method in your controller to define how to find the
|
|
20
34
|
# versioned resource.
|
|
21
35
|
def versioned_resource
|
|
@@ -22,14 +22,14 @@ module Decidim
|
|
|
22
22
|
if amendment_draft
|
|
23
23
|
redirect_to edit_draft_amend_path(amendment_draft)
|
|
24
24
|
else
|
|
25
|
-
@form = form(Decidim::Amendable::CreateForm).from_params(
|
|
25
|
+
@form = form(Decidim::Amendable::CreateForm).from_params(create_params)
|
|
26
26
|
end
|
|
27
27
|
end
|
|
28
28
|
|
|
29
29
|
def create
|
|
30
30
|
enforce_permission_to :create, :amendment, current_component: amendable.component
|
|
31
31
|
|
|
32
|
-
@form = form(Decidim::Amendable::CreateForm).from_params(
|
|
32
|
+
@form = form(Decidim::Amendable::CreateForm).from_params(create_params)
|
|
33
33
|
|
|
34
34
|
Decidim::Amendable::CreateDraft.call(@form) do
|
|
35
35
|
on(:ok) do |amendment|
|
|
@@ -145,13 +145,13 @@ module Decidim
|
|
|
145
145
|
def review
|
|
146
146
|
enforce_permission_to :accept, :amendment, amendable:, current_component: amendable.component
|
|
147
147
|
|
|
148
|
-
@form = form(Decidim::Amendable::ReviewForm).from_params(
|
|
148
|
+
@form = form(Decidim::Amendable::ReviewForm).from_params(review_params)
|
|
149
149
|
end
|
|
150
150
|
|
|
151
151
|
def accept
|
|
152
152
|
enforce_permission_to :accept, :amendment, amendable:, current_component: amendable.component
|
|
153
153
|
|
|
154
|
-
@form = form(Decidim::Amendable::ReviewForm).from_params(
|
|
154
|
+
@form = form(Decidim::Amendable::ReviewForm).from_params(review_params)
|
|
155
155
|
|
|
156
156
|
Decidim::Amendable::Accept.call(@form) do
|
|
157
157
|
on(:ok) do |emendation|
|
|
@@ -190,12 +190,40 @@ module Decidim
|
|
|
190
190
|
params[:amendable_gid] || params.dig(:amendment, :amendable_gid)
|
|
191
191
|
end
|
|
192
192
|
|
|
193
|
+
# Binds the create form to the already-checked amendable, so a conflicting
|
|
194
|
+
# nested `amendment[amendable_gid]` cannot select another resource.
|
|
195
|
+
def create_params
|
|
196
|
+
params.deep_merge(amendment: { amendable_gid: amendable&.to_sgid&.to_s })
|
|
197
|
+
end
|
|
198
|
+
|
|
199
|
+
# Binds the review form to the amendment from the route, so a nested
|
|
200
|
+
# `amendment[id]` cannot select a different amendment.
|
|
201
|
+
def review_params
|
|
202
|
+
params.deep_merge(amendment: { id: amendment&.id })
|
|
203
|
+
end
|
|
204
|
+
|
|
193
205
|
def amendment
|
|
194
|
-
@amendment ||= Decidim::Amendment.find_by(id: params[:id])
|
|
206
|
+
@amendment ||= Decidim::Amendment.find_by(id: params[:id]) # rubocop:disable Decidim/OrganizationScopedFinder -- Amendment has no organization column; #amendable validates the owning resource
|
|
195
207
|
end
|
|
196
208
|
|
|
197
209
|
def amendable
|
|
198
|
-
@amendable ||=
|
|
210
|
+
@amendable ||= begin
|
|
211
|
+
# Existing amendments must always resolve their own amendable, so a
|
|
212
|
+
# foreign amendment cannot be authorized through a local
|
|
213
|
+
# `amendable_gid` supplied alongside its id. The signed resource is
|
|
214
|
+
# only used when creating an amendment.
|
|
215
|
+
resource = if creating_amendment?
|
|
216
|
+
GlobalID::Locator.locate_signed(amendable_gid)
|
|
217
|
+
else
|
|
218
|
+
amendment&.amendable
|
|
219
|
+
end
|
|
220
|
+
ensure_in_organization!(resource)
|
|
221
|
+
resource
|
|
222
|
+
end
|
|
223
|
+
end
|
|
224
|
+
|
|
225
|
+
def creating_amendment?
|
|
226
|
+
%w(new create).include?(action_name)
|
|
199
227
|
end
|
|
200
228
|
|
|
201
229
|
def emendation
|
|
@@ -28,6 +28,7 @@ module Decidim
|
|
|
28
28
|
include ActiveStorage::SetCurrent
|
|
29
29
|
include OnboardingActionMethods
|
|
30
30
|
include EphemeralSessionChecker
|
|
31
|
+
include Decidim::UrlHelper
|
|
31
32
|
|
|
32
33
|
helper Decidim::MetaTagsHelper
|
|
33
34
|
helper Decidim::DecidimFormHelper
|
|
@@ -44,6 +45,7 @@ module Decidim
|
|
|
44
45
|
helper Decidim::SocialShareButtonHelper
|
|
45
46
|
helper Decidim::FiltersHelper
|
|
46
47
|
helper Decidim::OnboardingActionHelper
|
|
48
|
+
helper Decidim::UrlHelper
|
|
47
49
|
|
|
48
50
|
register_permissions(::Decidim::ApplicationController,
|
|
49
51
|
::Decidim::Admin::Permissions,
|
|
@@ -59,12 +61,6 @@ module Decidim
|
|
|
59
61
|
|
|
60
62
|
skip_before_action :disable_http_caching, unless: :user_signed_in?
|
|
61
63
|
|
|
62
|
-
def store_share_token
|
|
63
|
-
session[:share_token] = params[:share_token] if params.has_key?(:share_token)
|
|
64
|
-
|
|
65
|
-
session[:share_token].presence
|
|
66
|
-
end
|
|
67
|
-
|
|
68
64
|
private
|
|
69
65
|
|
|
70
66
|
def allow_browser(**); end
|
|
@@ -6,6 +6,8 @@ module Decidim
|
|
|
6
6
|
layout false
|
|
7
7
|
|
|
8
8
|
def show
|
|
9
|
+
enforce_permission_to :read, :authorization
|
|
10
|
+
|
|
9
11
|
store_onboarding_cookie_data!(current_user)
|
|
10
12
|
end
|
|
11
13
|
|
|
@@ -23,7 +25,7 @@ module Decidim
|
|
|
23
25
|
end
|
|
24
26
|
|
|
25
27
|
def current_component
|
|
26
|
-
@current_component ||= Decidim::Component.where(participatory_space: current_organization.participatory_spaces).find(params[:component_id])
|
|
28
|
+
@current_component ||= Decidim::Component.where(participatory_space: current_organization.participatory_spaces).find(params[:component_id]) # rubocop:disable Decidim/OrganizationScopedFinder -- participatory_spaces is scoped to current_organization
|
|
27
29
|
end
|
|
28
30
|
|
|
29
31
|
def authorization_action
|
|
@@ -67,6 +67,8 @@ module Decidim
|
|
|
67
67
|
raise ActionController::RoutingError, "Not Found" unless current_user_can_visit_space?
|
|
68
68
|
end
|
|
69
69
|
|
|
70
|
+
protected
|
|
71
|
+
|
|
70
72
|
def set_breadcrumb_items
|
|
71
73
|
context_breadcrumb_items << add_current_component
|
|
72
74
|
context_breadcrumb_items << add_parent_breadcrumb_item
|
|
@@ -14,6 +14,8 @@ module Decidim
|
|
|
14
14
|
before_action :check_sign_in_enabled
|
|
15
15
|
|
|
16
16
|
def change_password
|
|
17
|
+
enforce_permission_to(:update, :user, current_user:)
|
|
18
|
+
|
|
17
19
|
self.resource = current_user
|
|
18
20
|
@send_path = apply_password_path
|
|
19
21
|
|
|
@@ -22,6 +24,8 @@ module Decidim
|
|
|
22
24
|
end
|
|
23
25
|
|
|
24
26
|
def apply_password
|
|
27
|
+
enforce_permission_to(:update, :user, current_user:)
|
|
28
|
+
|
|
25
29
|
self.resource = current_user
|
|
26
30
|
@send_path = apply_password_path
|
|
27
31
|
|
|
@@ -43,6 +47,10 @@ module Decidim
|
|
|
43
47
|
|
|
44
48
|
private
|
|
45
49
|
|
|
50
|
+
def user_has_no_permission_path
|
|
51
|
+
new_user_session_path
|
|
52
|
+
end
|
|
53
|
+
|
|
46
54
|
def check_sign_in_enabled
|
|
47
55
|
redirect_to new_user_session_path unless current_organization.sign_in_enabled?
|
|
48
56
|
end
|
|
@@ -6,8 +6,12 @@ module Decidim
|
|
|
6
6
|
class AuthorizationsController < ::Doorkeeper::AuthorizationsController
|
|
7
7
|
include HasSpecificBreadcrumb
|
|
8
8
|
|
|
9
|
+
before_action :set_oauth_application
|
|
10
|
+
|
|
9
11
|
helper_method :oauth_application, :all_abilities?
|
|
10
12
|
|
|
13
|
+
attr_reader :oauth_application
|
|
14
|
+
|
|
11
15
|
def new
|
|
12
16
|
@scopes =
|
|
13
17
|
if pre_auth.authorizable?
|
|
@@ -19,10 +23,6 @@ module Decidim
|
|
|
19
23
|
super
|
|
20
24
|
end
|
|
21
25
|
|
|
22
|
-
def oauth_application
|
|
23
|
-
@oauth_application ||= Decidim::OAuthApplication.find_by(uid: params[:client_id])
|
|
24
|
-
end
|
|
25
|
-
|
|
26
26
|
def breadcrumb_item
|
|
27
27
|
{
|
|
28
28
|
label: t("decidim.doorkeeper.authorizations.new.authorize"),
|
|
@@ -32,6 +32,12 @@ module Decidim
|
|
|
32
32
|
|
|
33
33
|
private
|
|
34
34
|
|
|
35
|
+
def set_oauth_application
|
|
36
|
+
return if params[:client_id].blank?
|
|
37
|
+
|
|
38
|
+
@oauth_application = current_organization.oauth_applications.find_by!(uid: params.expect(:client_id))
|
|
39
|
+
end
|
|
40
|
+
|
|
35
41
|
def all_abilities?
|
|
36
42
|
%w(api:read api:write).all? { |scope| @scopes.include?(scope) } &&
|
|
37
43
|
%w(profile user).any? { |scope| @scopes.include?(scope) }
|
|
@@ -5,6 +5,7 @@ module Decidim
|
|
|
5
5
|
# A controller to expose a simple JSON API so OAuth clients can get the user's information.
|
|
6
6
|
class CredentialsController < ApplicationController
|
|
7
7
|
before_action :doorkeeper_authorize!
|
|
8
|
+
before_action :validate_token_organization!
|
|
8
9
|
respond_to :json
|
|
9
10
|
|
|
10
11
|
def me
|
|
@@ -23,8 +24,12 @@ module Decidim
|
|
|
23
24
|
}
|
|
24
25
|
end
|
|
25
26
|
|
|
27
|
+
def validate_token_organization!
|
|
28
|
+
ensure_in_organization!(doorkeeper_token&.application)
|
|
29
|
+
end
|
|
30
|
+
|
|
26
31
|
def current_resource_owner
|
|
27
|
-
@current_resource_owner ||=
|
|
32
|
+
@current_resource_owner ||= current_organization.users.find(doorkeeper_token.resource_owner_id) if doorkeeper_token
|
|
28
33
|
end
|
|
29
34
|
|
|
30
35
|
def avatar_url
|
|
@@ -12,6 +12,7 @@ module Decidim
|
|
|
12
12
|
class FaviconController < ::DecidimController
|
|
13
13
|
include ActionController::DataStreaming # For Rails 7, check out `ActiveStorage::Streaming`.
|
|
14
14
|
include NeedsOrganization
|
|
15
|
+
include NeedsPermission
|
|
15
16
|
|
|
16
17
|
skip_before_action :verify_authenticity_token, :verify_organization
|
|
17
18
|
skip_after_action :verify_same_origin_request
|
|
@@ -52,5 +53,13 @@ module Decidim
|
|
|
52
53
|
|
|
53
54
|
@favicon_blob ||= current_organization.favicon_ico&.blob
|
|
54
55
|
end
|
|
56
|
+
|
|
57
|
+
def permission_class_chain
|
|
58
|
+
[Decidim::Permissions]
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
def permission_scope
|
|
62
|
+
:public
|
|
63
|
+
end
|
|
55
64
|
end
|
|
56
65
|
end
|
|
@@ -9,7 +9,7 @@ module Decidim
|
|
|
9
9
|
helper_method :like_button
|
|
10
10
|
# we need to declare with +helper+ to be able to call :render_like_identity from the views
|
|
11
11
|
helper Decidim::LikeableHelper
|
|
12
|
-
helper_method :resource
|
|
12
|
+
helper_method :resource, :current_component
|
|
13
13
|
|
|
14
14
|
before_action :authenticate_user!
|
|
15
15
|
|
|
@@ -4,6 +4,8 @@ module Decidim
|
|
|
4
4
|
# A controller to serve the manifest file for PWA
|
|
5
5
|
class ManifestsController < Decidim::ApplicationController
|
|
6
6
|
def show
|
|
7
|
+
enforce_permission_to :read, :manifest
|
|
8
|
+
|
|
7
9
|
organization_presenter = OrganizationPresenter.new(current_organization)
|
|
8
10
|
render layout: false, locals: { organization_params: organization_presenter }, content_type: "application/manifest+json"
|
|
9
11
|
end
|
|
@@ -43,10 +43,7 @@ module Decidim
|
|
|
43
43
|
|
|
44
44
|
StartConversation.call(@form) do
|
|
45
45
|
on(:ok) do |conversation|
|
|
46
|
-
render action: :create, locals: {
|
|
47
|
-
conversation:,
|
|
48
|
-
form: MessageForm.new
|
|
49
|
-
}
|
|
46
|
+
render action: :create, locals: { conversation: }
|
|
50
47
|
end
|
|
51
48
|
|
|
52
49
|
on(:invalid) do |messages|
|
|
@@ -96,6 +93,15 @@ module Decidim
|
|
|
96
93
|
|
|
97
94
|
def check_multiple
|
|
98
95
|
@form = form(ConversationForm).from_params(params, sender: current_user)
|
|
96
|
+
|
|
97
|
+
conversation = conversation_between_multiple(@form.recipient.to_a.prepend(current_user))
|
|
98
|
+
|
|
99
|
+
if conversation
|
|
100
|
+
enforce_permission_to :read, :conversation, conversation:
|
|
101
|
+
else
|
|
102
|
+
enforce_permission_to :create, :conversation, conversation: new_conversation(@form.recipient)
|
|
103
|
+
end
|
|
104
|
+
|
|
99
105
|
redirect_link = current_or_new_conversation_path_with_multiple(@form.recipient, nickname: params[:nickname])
|
|
100
106
|
redirect_to redirect_link
|
|
101
107
|
end
|
|
@@ -107,7 +113,7 @@ module Decidim
|
|
|
107
113
|
end
|
|
108
114
|
|
|
109
115
|
def conversation
|
|
110
|
-
@conversation ||= Conversation.find(params[:id])
|
|
116
|
+
@conversation ||= Conversation.find(params[:id]) # rubocop:disable Decidim/OrganizationScopedFinder -- conversation permissions require the current user to be a participant
|
|
111
117
|
end
|
|
112
118
|
|
|
113
119
|
def new_conversation(recipient)
|
|
@@ -11,6 +11,8 @@ module Decidim
|
|
|
11
11
|
helper_method :newsletter
|
|
12
12
|
|
|
13
13
|
def show
|
|
14
|
+
enforce_permission_to :read, :newsletter
|
|
15
|
+
|
|
14
16
|
@user = current_user
|
|
15
17
|
@organization = current_organization
|
|
16
18
|
|
|
@@ -20,6 +22,8 @@ module Decidim
|
|
|
20
22
|
end
|
|
21
23
|
|
|
22
24
|
def unsubscribe
|
|
25
|
+
enforce_permission_to :unsubscribe, :newsletter
|
|
26
|
+
|
|
23
27
|
encryptor = Decidim::NewsletterEncryptor
|
|
24
28
|
|
|
25
29
|
decrypted_string = encryptor.sent_at_decrypted(params[:u])
|
|
@@ -6,11 +6,15 @@ module Decidim
|
|
|
6
6
|
rescue_from Decidim::NotificationsSubscriptionsPersistor::UnsupportedPushSubscriptionEndpointError, with: :unsupported_browser
|
|
7
7
|
|
|
8
8
|
def create
|
|
9
|
+
enforce_permission_to(:update, :user, current_user:)
|
|
10
|
+
|
|
9
11
|
Decidim::NotificationsSubscriptionsPersistor.new(current_user).add_subscription(params)
|
|
10
12
|
head :ok
|
|
11
13
|
end
|
|
12
14
|
|
|
13
15
|
def destroy
|
|
16
|
+
enforce_permission_to(:update, :user, current_user:)
|
|
17
|
+
|
|
14
18
|
Decidim::NotificationsSubscriptionsPersistor.new(current_user).delete_subscription(params[:auth])
|
|
15
19
|
head :ok
|
|
16
20
|
end
|
|
@@ -4,9 +4,13 @@ module Decidim
|
|
|
4
4
|
class OpenDataController < Decidim::ApplicationController
|
|
5
5
|
helper_method :open_data_component_manifests, :open_data_participatory_space_manifests, :open_data_core_manifests
|
|
6
6
|
|
|
7
|
-
def index
|
|
7
|
+
def index
|
|
8
|
+
enforce_permission_to :read, :open_data
|
|
9
|
+
end
|
|
8
10
|
|
|
9
11
|
def download
|
|
12
|
+
enforce_permission_to :read, :open_data
|
|
13
|
+
|
|
10
14
|
resource = params[:resource] || nil
|
|
11
15
|
|
|
12
16
|
if open_data_file_for_resource(resource)
|
|
@@ -10,6 +10,10 @@ module Decidim
|
|
|
10
10
|
|
|
11
11
|
before_action :legacy_redirect, :set_default_request_format
|
|
12
12
|
|
|
13
|
+
# Included after the legacy redirect so its before_action does not look the
|
|
14
|
+
# page up (and 404) before the redirect happens.
|
|
15
|
+
include HasSpecificBreadcrumb
|
|
16
|
+
|
|
13
17
|
def index
|
|
14
18
|
enforce_permission_to :read, :public_page
|
|
15
19
|
@topics = StaticPageTopic.where(organization: current_organization)
|
|
@@ -17,14 +21,38 @@ module Decidim
|
|
|
17
21
|
end
|
|
18
22
|
|
|
19
23
|
def show
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
@topic =
|
|
24
|
+
enforce_permission_to :read, :public_page, page:
|
|
25
|
+
|
|
26
|
+
@topic = page.topic
|
|
23
27
|
@pages = @topic&.pages
|
|
24
28
|
end
|
|
25
29
|
|
|
26
30
|
private
|
|
27
31
|
|
|
32
|
+
def page
|
|
33
|
+
@page ||= current_organization.static_pages.find_by!(slug: params.expect(:id))
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
def breadcrumb_item
|
|
37
|
+
items = [
|
|
38
|
+
{
|
|
39
|
+
label: t("decidim.pages.index.title"),
|
|
40
|
+
active: action_name == "index",
|
|
41
|
+
url: pages_path
|
|
42
|
+
}
|
|
43
|
+
]
|
|
44
|
+
|
|
45
|
+
if action_name == "show"
|
|
46
|
+
items << {
|
|
47
|
+
label: page.title,
|
|
48
|
+
active: true,
|
|
49
|
+
url: page_path(page)
|
|
50
|
+
}
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
items
|
|
54
|
+
end
|
|
55
|
+
|
|
28
56
|
def legacy_redirect
|
|
29
57
|
return redirect_to decidim.page_path("terms-of-service") if params[:id] == "terms-and-conditions"
|
|
30
58
|
end
|
|
@@ -15,30 +15,41 @@ module Decidim
|
|
|
15
15
|
before_action :ensure_profile_holder
|
|
16
16
|
before_action :ensure_profile_holder_is_a_user, only: :following
|
|
17
17
|
before_action :ensure_user_not_blocked
|
|
18
|
+
before_action :ensure_user_not_deleted
|
|
18
19
|
|
|
19
20
|
def show
|
|
20
|
-
|
|
21
|
+
enforce_permission_to :read, :profile
|
|
22
|
+
|
|
23
|
+
redirect_to profile_activity_path(nickname: params.expect(:nickname).downcase)
|
|
21
24
|
end
|
|
22
25
|
|
|
23
26
|
def following
|
|
27
|
+
enforce_permission_to :read, :profile
|
|
28
|
+
|
|
24
29
|
@content_cell = "decidim/following"
|
|
25
30
|
@title_key = "following"
|
|
26
31
|
render :show
|
|
27
32
|
end
|
|
28
33
|
|
|
29
34
|
def followers
|
|
35
|
+
enforce_permission_to :read, :profile
|
|
36
|
+
|
|
30
37
|
@content_cell = "decidim/followers"
|
|
31
38
|
@title_key = "followers"
|
|
32
39
|
render :show
|
|
33
40
|
end
|
|
34
41
|
|
|
35
42
|
def badges
|
|
43
|
+
enforce_permission_to :read, :profile
|
|
44
|
+
|
|
36
45
|
@content_cell = "decidim/badges"
|
|
37
46
|
@title_key = "badges"
|
|
38
47
|
render :show
|
|
39
48
|
end
|
|
40
49
|
|
|
41
50
|
def activity
|
|
51
|
+
enforce_permission_to :read, :profile
|
|
52
|
+
|
|
42
53
|
@content_cell = "decidim/user_activity"
|
|
43
54
|
@title_key = "activity"
|
|
44
55
|
render :show
|
|
@@ -46,6 +57,13 @@ module Decidim
|
|
|
46
57
|
|
|
47
58
|
private
|
|
48
59
|
|
|
60
|
+
# Deleted users should not normally have a nickname, so in normal situation
|
|
61
|
+
# this should not be possible, but in some edge cases there may be accounts
|
|
62
|
+
# left behind with the username field still available.
|
|
63
|
+
def ensure_user_not_deleted
|
|
64
|
+
raise ActionController::RoutingError, "Deleted User" if profile_holder&.deleted?
|
|
65
|
+
end
|
|
66
|
+
|
|
49
67
|
def ensure_user_not_blocked
|
|
50
68
|
raise ActionController::RoutingError, "Blocked User" if profile_holder&.blocked? && !current_user&.admin?
|
|
51
69
|
end
|
|
@@ -61,7 +79,7 @@ module Decidim
|
|
|
61
79
|
def profile_holder
|
|
62
80
|
return if params[:nickname].blank?
|
|
63
81
|
|
|
64
|
-
@profile_holder ||=
|
|
82
|
+
@profile_holder ||= current_organization.user_entities.find_by(nickname: params[:nickname].downcase)
|
|
65
83
|
end
|
|
66
84
|
end
|
|
67
85
|
end
|
|
@@ -7,7 +7,7 @@ module Decidim
|
|
|
7
7
|
include Decidim::OrganizationHelper
|
|
8
8
|
include Decidim::QrCodeHelper
|
|
9
9
|
|
|
10
|
-
helper_method :resource, :qr_code, :qr_code_image
|
|
10
|
+
helper_method :resource, :qr_code, :qr_code_image, :current_component, :current_participatory_space
|
|
11
11
|
before_action :validate_resource
|
|
12
12
|
before_action :validate_component
|
|
13
13
|
before_action :validate_participatory_space
|
|
@@ -15,6 +15,8 @@ module Decidim
|
|
|
15
15
|
layout false
|
|
16
16
|
|
|
17
17
|
def show
|
|
18
|
+
enforce_permission_to :read, :qr_code
|
|
19
|
+
|
|
18
20
|
respond_to do |format|
|
|
19
21
|
format.html
|
|
20
22
|
format.png { send_data(qr_code.as_png(size: 500), filename: "qr-#{organization_name}-#{parametrized_title}.png") }
|
|
@@ -12,6 +12,8 @@ module Decidim
|
|
|
12
12
|
helper_method :term
|
|
13
13
|
|
|
14
14
|
def index
|
|
15
|
+
enforce_permission_to :read, :search
|
|
16
|
+
|
|
15
17
|
Search.call(term, current_organization, filters, page_params) do
|
|
16
18
|
on(:ok) do |results|
|
|
17
19
|
results_count = results.sum { |results_by_type| results_by_type.last[:count] }
|
|
@@ -8,6 +8,8 @@ module Decidim
|
|
|
8
8
|
# The index action redirects the user to the application root in case
|
|
9
9
|
# someone tries to request the short link URL without an identifier.
|
|
10
10
|
def index
|
|
11
|
+
enforce_permission_to :read, :short_link
|
|
12
|
+
|
|
11
13
|
redirect_to decidim.root_path, status: :moved_permanently
|
|
12
14
|
end
|
|
13
15
|
|
|
@@ -18,6 +20,8 @@ module Decidim
|
|
|
18
20
|
# @raise [ActionController::RoutingError] if a short link does not exist
|
|
19
21
|
# with the given identifier
|
|
20
22
|
def show
|
|
23
|
+
enforce_permission_to :read, :short_link
|
|
24
|
+
|
|
21
25
|
raise ActionController::RoutingError, "Not Found" unless link
|
|
22
26
|
|
|
23
27
|
redirect_to link.target_url, status: :moved_permanently
|