Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release 2024-10-11 #9086

Merged
merged 135 commits into from
Oct 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
135 commits
Select commit Hold shift + click to select a range
741823f
WIP add prev and next buttons to idea page
amanda-anderson May 21, 2024
1f4e914
WIP connect to BE and code cleanup
amanda-anderson May 21, 2024
8b9a6f0
WIP new next previous buttons component
amanda-anderson May 21, 2024
2e51d46
Add aria message and hide next previous buttons if no phase context i…
amanda-anderson May 21, 2024
9520188
Merge branch 'master' into TAN-1268-idea-nav-improvements
amanda-anderson May 21, 2024
f7fbd51
Translations updated by CI (extract-intl)
May 21, 2024
a9f8d4e
Make aria message more descriptive
amanda-anderson May 21, 2024
087fa82
Merge branch 'TAN-1268-idea-nav-improvements' of github.com:CitizenLa…
amanda-anderson May 21, 2024
045dd38
Translations updated by CI (extract-intl)
May 21, 2024
e4a9e71
Only append phase_context to URL if present
amanda-anderson May 21, 2024
68a2f50
Merge branch 'TAN-1268-idea-nav-improvements' of github.com:CitizenLa…
amanda-anderson May 21, 2024
f074511
Add phase_context search param to sharing URLs
amanda-anderson May 21, 2024
3466d2c
Clean up code
amanda-anderson May 27, 2024
5bad9fb
Use new mini idea endpoint
amanda-anderson May 27, 2024
b8f8827
Code cleanup
amanda-anderson May 27, 2024
1ae6cec
Fix up endpoint
amanda-anderson May 27, 2024
ddc4684
Merge branch 'master' into TAN-1268-idea-nav-improvements
amanda-anderson May 27, 2024
9d4075c
Merge with master
amanda-anderson May 27, 2024
4c7e689
Translations updated by CI (extract-intl)
May 27, 2024
2f89f6b
Merge with master
amanda-anderson May 27, 2024
cc4fc82
Fixes from code review
amanda-anderson May 31, 2024
0f706b4
Add aria live
amanda-anderson May 31, 2024
3fa678d
Translations updated by CI (extract-intl)
May 31, 2024
7ceb4f7
Merge branch 'master' into TAN-1268-idea-nav-improvements
amanda-anderson Jun 3, 2024
0c121c8
Merge branch 'TAN-1268-idea-nav-improvements' of github.com:CitizenLa…
amanda-anderson Jun 3, 2024
d773098
Add accessibility handling
amanda-anderson Jun 3, 2024
23b46db
Code cleanup
amanda-anderson Jun 3, 2024
f97e35b
Revert line
amanda-anderson Jun 3, 2024
d67dc77
Remove weglot file
amanda-anderson Jun 3, 2024
6a48068
Merge with master
amanda-anderson Jun 10, 2024
2aeb3c6
move permission logic from idea policy to editing_idea action descrip…
sebastienhoorens Sep 5, 2024
0266553
support editing_idea in permission services without having correspond…
sebastienhoorens Sep 5, 2024
d0798f7
remove duplication between project policy show and project permission…
sebastienhoorens Sep 5, 2024
3e57024
remove duplicate project visibility logic in idea update policy + use…
sebastienhoorens Sep 5, 2024
bf9915a
create consistent ideas by factory
sebastienhoorens Sep 5, 2024
0be4e45
fixing specs: idea phase issues
sebastienhoorens Sep 5, 2024
30d0ac5
fixing specs: idea phase issues
sebastienhoorens Sep 5, 2024
abdcbb9
fixing specs: idea phase issues
sebastienhoorens Sep 5, 2024
66436ee
fix offenses
sebastienhoorens Sep 5, 2024
bcb702a
fixing specs: idea phase issues
sebastienhoorens Sep 5, 2024
ebe340c
fixing specs: idea phase issues
sebastienhoorens Sep 5, 2024
f70e955
fixing specs: idea phase issues
sebastienhoorens Sep 5, 2024
5da2211
fixing specs: idea phase issues
sebastienhoorens Sep 5, 2024
7f6f914
move votes exist and published after screening denied reasons from po…
sebastienhoorens Sep 5, 2024
22a7bb3
only check votes and published after screening for editing action
sebastienhoorens Sep 5, 2024
2a434cb
added future_enabled_at for editing_idea
sebastienhoorens Sep 5, 2024
8077175
fix offenses
sebastienhoorens Sep 5, 2024
e2e694e
update -> update! in specs
sebastienhoorens Sep 5, 2024
e16031e
do not require input to be in current phase for editing
sebastienhoorens Sep 9, 2024
a4bb566
fix offenses
sebastienhoorens Sep 9, 2024
503da93
[TAN-2518] Added basic structure of keycloak for ID-Porten
jamesspeake Sep 13, 2024
628082b
Made IdeaPermissionsService for editing_idea consistent with update? …
kogre Sep 14, 2024
c84f240
Merge branch 'bundle-audit/upgrade-omniauth-saml' into TAN-2518-oslo-…
jamesspeake Sep 16, 2024
2f5730b
[TAN-2518] Got tests passing for ID-Porten - awaiting implementation …
jamesspeake Sep 17, 2024
7586188
[TAN-2518] Rubocop fix
jamesspeake Sep 17, 2024
946b11b
[TAN-2518] Added front end components for ID-Porten
jamesspeake Sep 17, 2024
a4b0069
Merge branch 'master' into TAN-2518-oslo-id-porten
jamesspeake Sep 17, 2024
dae1aeb
Idea editting permissions front-end
IvaKop Sep 25, 2024
ce77e92
Added make shortcuts to enable testing of SSO methods
jamesspeake Sep 27, 2024
69ecd0b
Merge in master
amanda-anderson Oct 1, 2024
bbe22a5
Merge in master
amanda-anderson Oct 1, 2024
e9f4f61
Translations updated by CI (extract-intl)
Oct 1, 2024
bb126a1
Fix error in unit test
amanda-anderson Oct 1, 2024
123d67a
Merge branch 'TAN-1268-idea-nav-improvements' of github.com:CitizenLa…
amanda-anderson Oct 1, 2024
8a56a4e
manual merge
sebastienhoorens Oct 1, 2024
9a28cd9
fixing frontend build errors (missing editing_idea action descriptor)
sebastienhoorens Oct 1, 2024
c5d86e6
Remove deadcode
amanda-anderson Oct 1, 2024
d2de677
fix participated in project spec
sebastienhoorens Oct 1, 2024
ec7561a
revert move of moderator guard
sebastienhoorens Oct 1, 2024
c5c3e30
turn policy specs green after restoring behaviour described by accept…
sebastienhoorens Oct 1, 2024
c7ebb5d
WIP move idea nav buttons higher on idea show page
amanda-anderson Oct 2, 2024
ee05cce
Fix accessibility issues
amanda-anderson Oct 3, 2024
2395550
Merge branch 'master' into TAN-1268-idea-nav-improvements
amanda-anderson Oct 7, 2024
bfc8836
Merge branch 'master' into TAN-2518-oslo-id-porten
jamesspeake Oct 7, 2024
dacf5ac
Merge branch 'sso-testing-shortcuts' into TAN-2518-oslo-id-porten
jamesspeake Oct 7, 2024
5379270
Merge branch 'master' into idea-editing-allowed-in-serializer
kogre Oct 7, 2024
7f81f53
[TNA-2518] Got keycloak (ID porten) working
jamesspeake Oct 7, 2024
d1868bc
[TNA-2518] Moved config to admin HQ
jamesspeake Oct 7, 2024
e4d2950
[TNA-2518] Updated logo
jamesspeake Oct 7, 2024
200753d
[TNA-2518] Removed unused code
jamesspeake Oct 7, 2024
0bf1a0b
[TNA-2518] Added ability to test without the feature flag being on
jamesspeake Oct 8, 2024
20d7181
[TNA-2518] Linting
jamesspeake Oct 8, 2024
7930dfd
Make action descriptor and idea policy align for editing_idea
kogre Oct 8, 2024
c9ecde0
Improve performance and explain diverging behavior of editing_idea pe…
kogre Oct 8, 2024
b303d49
TAN-2750 Added specs for idea visibility for cosponsors
kogre Oct 8, 2024
a8d7b8a
TAN-2750 Implement index permissions for ideas for cosponsors
kogre Oct 8, 2024
aa28f5c
Fixed ideas spec for new action descriptor value
kogre Oct 8, 2024
e724e00
Merge branch 'idea-editing-allowed-in-serializer' into TAN-2750-cospo…
kogre Oct 8, 2024
c5a166c
Rubocop fixes
kogre Oct 8, 2024
16c0fab
Fix idea show policy for cosponsors
kogre Oct 8, 2024
6e9d77e
Merge branch 'master' into idea-editing-allowed-in-serializer
kogre Oct 8, 2024
7f7c327
Merge branch 'master' into TAN-1268-idea-nav-improvements
amanda-anderson Oct 9, 2024
452d688
Merge pull request #7950 from CitizenLabDotCo/TAN-1268-idea-nav-impro…
amanda-anderson Oct 9, 2024
a153f23
New translations en.json (French)
cl-dev-bot Oct 9, 2024
333ddf2
New translations en.json (Spanish)
cl-dev-bot Oct 9, 2024
bc5dba3
New translations en.json (Arabic)
cl-dev-bot Oct 9, 2024
da0d623
New translations en.json (Catalan)
cl-dev-bot Oct 9, 2024
0cffbe2
New translations en.json (Danish)
cl-dev-bot Oct 9, 2024
e971960
New translations en.json (German)
cl-dev-bot Oct 9, 2024
ab3ebc1
New translations en.json (Greek)
cl-dev-bot Oct 9, 2024
e458e2d
New translations en.json (Finnish)
cl-dev-bot Oct 9, 2024
da5c21b
New translations en.json (Italian)
cl-dev-bot Oct 9, 2024
111cb6a
New translations en.json (Dutch)
cl-dev-bot Oct 9, 2024
62b12f7
New translations en.json (Norwegian)
cl-dev-bot Oct 9, 2024
04a1fc1
New translations en.json (Polish)
cl-dev-bot Oct 9, 2024
628c113
New translations en.json (Serbian (Cyrillic))
cl-dev-bot Oct 9, 2024
847691a
New translations en.json (Swedish)
cl-dev-bot Oct 9, 2024
41400e7
New translations en.json (Turkish)
cl-dev-bot Oct 9, 2024
146014e
New translations en.json (Portuguese, Brazilian)
cl-dev-bot Oct 9, 2024
e9a084b
New translations en.json (Spanish, Chile)
cl-dev-bot Oct 9, 2024
dbb587e
New translations en.json (Croatian)
cl-dev-bot Oct 9, 2024
e6f5b94
New translations en.json (Latvian)
cl-dev-bot Oct 9, 2024
2a66360
New translations en.json (English, Canada)
cl-dev-bot Oct 9, 2024
3988cec
New translations en.json (English, United Kingdom)
cl-dev-bot Oct 9, 2024
0094480
New translations en.json (Welsh)
cl-dev-bot Oct 9, 2024
d9ed727
New translations en.json (Luxembourgish)
cl-dev-bot Oct 9, 2024
03693d6
New translations en.json (Serbian (Latin))
cl-dev-bot Oct 9, 2024
7ead8ad
New translations en.json (Dutch, Belgium)
cl-dev-bot Oct 9, 2024
cfdb8ce
New translations en.json (English, Ireland)
cl-dev-bot Oct 9, 2024
2a370f2
New translations en.json (French, Belgium)
cl-dev-bot Oct 9, 2024
8d3b17b
New translations en.json (Moroccan Arabic)
cl-dev-bot Oct 9, 2024
6bd0e79
New translations en.json (Acholi)
cl-dev-bot Oct 9, 2024
a7ad27e
Merge pull request #9075 from CitizenLabDotCo/l10n_master
amanda-anderson Oct 9, 2024
6faca5b
Test turning off ssl_mode
jamesspeake Oct 9, 2024
e78531a
Merge pull request #9067 from CitizenLabDotCo/TAN-2750-cosponsor-inpu…
kogre Oct 9, 2024
fa3a201
fix gen_random_uuid()
jamesspeake Oct 9, 2024
c494c45
Merge pull request #8834 from CitizenLabDotCo/idea-editing-allowed-in…
kogre Oct 9, 2024
8febbdd
Merge pull request #9078 from CitizenLabDotCo/js-epic-test
jamesspeake Oct 10, 2024
b028982
[TAN-2518] removed hardcoded redirect URI
jamesspeake Oct 10, 2024
4d57f7c
Fixed following sign-up flow
jamesspeake Oct 10, 2024
68f910e
Merge pull request #9081 from CitizenLabDotCo/fix-following
IvaKop Oct 10, 2024
8c42d7e
New translations en.json (Spanish)
cl-dev-bot Oct 10, 2024
f41afb0
New translations en.json (Spanish, Chile)
cl-dev-bot Oct 10, 2024
0f2a127
Merge pull request #9082 from CitizenLabDotCo/l10n_master
IvaKop Oct 10, 2024
79e0ee2
Merge pull request #8904 from CitizenLabDotCo/TAN-2518-oslo-id-porten
jamesspeake Oct 10, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,27 @@ fe-up:
up:
make -j 2 be-up fe-up

# For testing different SSO methods
be-up-claveunica:
docker compose down
BASE_DEV_URI=https://claveunica-h2dkc.loca.lt docker compose up -d
lt --print-requests --port 3000 --subdomain claveunica-h2dkc

be-up-nemlogin:
docker compose down
BASE_DEV_URI=https://nemlogin-k3kd.loca.lt docker compose up -d
lt --print-requests --port 3000 --subdomain nemlogin-k3kd

be-up-idaustria:
docker compose down
BASE_DEV_URI=https://idaustria-g3fy.loca.lt docker compose up -d
lt --print-requests --port 3000 --subdomain idaustria-g3fy

be-up-keycloak:
docker compose down
BASE_DEV_URI=https://keycloak-r3tyu.loca.lt docker compose up -d
lt --print-requests --port 3000 --subdomain keycloak-r3tyu

# Run it with:
# make c
# # or
Expand Down
1 change: 1 addition & 0 deletions back/Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,7 @@ commercial_engines = [
'id_franceconnect',
'id_gent_rrn',
'id_id_card_lookup',
'id_keycloak',
'id_nemlog_in',
'id_oostende_rrn',
# Some engines actually register an authentication method rather
Expand Down
9 changes: 9 additions & 0 deletions back/Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,14 @@ PATH
savon (>= 2.12, < 2.15)
verification

PATH
remote: engines/commercial/id_keycloak
specs:
id_keycloak (0.1.0)
omniauth_openid_connect (~> 0.7.1)
rails (~> 7.0)
verification

PATH
remote: engines/commercial/id_nemlog_in
specs:
Expand Down Expand Up @@ -1288,6 +1296,7 @@ DEPENDENCIES
id_gent_rrn!
id_hoplr!
id_id_card_lookup!
id_keycloak!
id_nemlog_in!
id_oostende_rrn!
id_vienna_saml!
Expand Down
6 changes: 3 additions & 3 deletions back/app/controllers/web_api/v1/ideas_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def index
def index_mini
ideas = IdeasFinder.new(
params,
scope: policy_scope(Idea).where(publication_status: 'published'),
scope: policy_scope(Idea).submitted_or_published,
current_user: current_user
).find_records
ideas = paginate SortByParamsService.new.sort_ideas(ideas, params, current_user)
Expand All @@ -60,7 +60,7 @@ def index_mini
def index_idea_markers
ideas = IdeasFinder.new(
params,
scope: policy_scope(Idea).where(publication_status: 'published'),
scope: policy_scope(Idea).submitted_or_published,
current_user: current_user
).find_records
ideas = paginate SortByParamsService.new.sort_ideas(ideas, params, current_user)
Expand All @@ -72,7 +72,7 @@ def index_idea_markers
def index_xlsx
ideas = IdeasFinder.new(
params.merge(filter_can_moderate: true),
scope: policy_scope(Idea).where(publication_status: 'published'),
scope: policy_scope(Idea).submitted_or_published,
current_user: current_user
).find_records
ideas = SortByParamsService.new.sort_ideas(ideas, params, current_user)
Expand Down
25 changes: 16 additions & 9 deletions back/app/policies/idea_policy.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# frozen_string_literal: true

class IdeaPolicy < ApplicationPolicy
EXCLUDED_REASONS_FOR_UPDATE = %w[posting_disabled posting_limited_max_reached].freeze
class Scope
attr_reader :user, :scope

Expand All @@ -17,6 +16,7 @@ def resolve
scope
.submitted_or_published.where(author: user)
.or(scope.published)
.or(scope.where(id: sponsored_ideas))
.where(project: Pundit.policy_scope(user, Project))
else
scope
Expand All @@ -25,6 +25,16 @@ def resolve
.where(projects: { visible_to: 'public', admin_publications: { publication_status: %w[published archived] } })
end
end

private

def sponsored_ideas
# Small optimization, where we check the feature flag to avoid the extra
# query, since this feature is turned off way more often than turned on
return [] unless AppConfiguration.instance.feature_activated?('input_cosponsorship')

Idea.joins(:cosponsorships).where(cosponsorships: { user_id: user.id })
end
end

def index_xlsx?
Expand Down Expand Up @@ -52,6 +62,7 @@ def show?

project_show = ProjectPolicy.new(user, record.project).show?
return true if project_show && %w[draft published].include?(record.publication_status)
return true if record.cosponsors.include?(user)

active? && (owner? || UserRoleService.new.can_moderate_project?(record.project, user))
end
Expand All @@ -67,16 +78,12 @@ def draft_by_phase?
def update?
return false if !record.participation_method_on_creation.supports_edits_after_publication? && record.published? && !record.will_be_published?
return true if (record.draft? && owner?) || (user && UserRoleService.new.can_moderate_project?(record.project, user))
return false unless active? && owner? && ProjectPolicy.new(user, record.project).show?
return false if record.participation_method_on_creation.use_reactions_as_votes? && record.reactions.where.not(user_id: user.id).exists?
return false if record.creation_phase&.prescreening_enabled && record.published?
return false if !active? || !owner?

posting_denied_reason = Permissions::ProjectPermissionsService.new(record.project, user).denied_reason_for_action 'posting_idea'
permission_action = record.will_be_published? ? 'posting_idea' : 'editing_idea'
posting_denied_reason = Permissions::IdeaPermissionsService.new(record, user).denied_reason_for_action permission_action
raise_not_authorized(posting_denied_reason) if posting_denied_reason

if posting_denied_reason
ignored_reasons = record.will_be_published? ? [] : EXCLUDED_REASONS_FOR_UPDATE
raise_not_authorized(posting_denied_reason) unless posting_denied_reason.in?(ignored_reasons)
end
true
end

Expand Down
12 changes: 3 additions & 9 deletions back/app/policies/project_policy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -80,15 +80,9 @@ def create?
end

def show?
active_moderator? || (
%w[published archived].include?(record.admin_publication.publication_status) && (
record.visible_to == 'public' || (
user &&
record.visible_to == 'groups' &&
user.in_any_groups?(record.groups)
)
)
)
return false if Permissions::ProjectPermissionsService.new(record, user).project_visible_disabled_reason

active_moderator? || %w[published archived].include?(record.admin_publication.publication_status)
end

def by_slug?
Expand Down
1 change: 1 addition & 0 deletions back/app/serializers/web_api/v1/idea_mini_serializer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@

class WebApi::V1::IdeaMiniSerializer < WebApi::V1::BaseSerializer
attributes :title_multiloc
attributes :slug
end
10 changes: 5 additions & 5 deletions back/app/services/permissions/base_permissions_service.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
module Permissions
class BasePermissionsService
SUPPORTED_ACTIONS = %w[
following
visiting
posting_initiative
commenting_initiative
reacting_initiative
Expand Down Expand Up @@ -32,6 +34,8 @@ def initialize(user, user_requirements_service: nil)
end

def denied_reason_for_action(action, scope: nil)
return unless supported_action? action

permission = find_permission(action, scope: scope)
user_denied_reason(permission)
end
Expand All @@ -41,9 +45,7 @@ def denied_reason_for_action(action, scope: nil)
attr_reader :user, :user_requirements_service

def supported_action?(action)
return true if SUPPORTED_ACTIONS.include? action

raise "Unsupported action: #{action}"
SUPPORTED_ACTIONS.include? action
end

def find_permission(action, scope: nil)
Expand All @@ -58,8 +60,6 @@ def find_permission(action, scope: nil)
end
end

raise "Unknown action '#{action}' for scope: #{scope}" if !permission

permission
end

Expand Down
42 changes: 36 additions & 6 deletions back/app/services/permissions/idea_permissions_service.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
module Permissions
class IdeaPermissionsService < ProjectPermissionsService
IDEA_DENIED_REASONS = {
idea_not_in_current_phase: 'idea_not_in_current_phase'
idea_not_in_current_phase: 'idea_not_in_current_phase',
votes_exist: 'votes_exist',
published_after_screening: 'published_after_screening',
not_author: 'not_author'
}.freeze

def initialize(idea, user, user_requirements_service: nil)
Expand All @@ -10,12 +13,33 @@ def initialize(idea, user, user_requirements_service: nil)
end

def denied_reason_for_action(action, reaction_mode: nil, delete_action: false)
reason = super
return reason if reason
case action
when 'editing_idea'
# We have different order of rules for editing_idea, in order to:
# 1) Support editing of ideas by admins/moderators, even if the project
# is no longer active
# 2) Performance optimization for the active descriptor, first checking
# whether user is the author before doing more heavier checks
# involving permissions and votes
return if user && UserRoleService.new.can_moderate_project?(idea.project, user)
return IDEA_DENIED_REASONS[:not_author] if (idea.author_id != user&.id) || idea.author_id.nil? || !user&.active?

current_phase = @timeline_service.current_phase_not_archived project
if current_phase && !idea_in_current_phase?(current_phase)
IDEA_DENIED_REASONS[:idea_not_in_current_phase]
reason = super
return reason if reason

return IDEA_DENIED_REASONS[:votes_exist] if idea.participation_method_on_creation.use_reactions_as_votes? && idea.reactions.where.not(user_id: user&.id).exists?

IDEA_DENIED_REASONS[:published_after_screening] if idea.creation_phase&.prescreening_enabled && idea.published?
else
reason = super
return reason if reason
return if user && UserRoleService.new.can_moderate_project?(idea.project, user)

# The input does not need to be in the current phase for editing.
# We preserved the behaviour that was already there, but we're not
# sure if this is the desired behaviour.
current_phase = @timeline_service.current_phase_not_archived project
IDEA_DENIED_REASONS[:idea_not_in_current_phase] if current_phase && !idea_in_current_phase?(current_phase)
end
end

Expand All @@ -24,6 +48,7 @@ def denied_reason_for_reaction_mode(reaction_mode, delete_action: false)
end

def action_descriptors
editing_disabled_reason = denied_reason_for_action 'editing_idea'
commenting_disabled_reason = denied_reason_for_action 'commenting_idea'
liking_disabled_reason = denied_reason_for_action 'reacting_idea', reaction_mode: 'up'
disliking_disabled_reason = denied_reason_for_action 'reacting_idea', reaction_mode: 'down'
Expand All @@ -32,6 +57,11 @@ def action_descriptors
comment_reacting_disabled_reason = commenting_disabled_reason

{
editing_idea: {
enabled: !editing_disabled_reason,
disabled_reason: editing_disabled_reason,
future_enabled_at: editing_disabled_reason && future_enabled_phase('editing_idea')&.start_at
},
commenting_idea: {
enabled: !commenting_disabled_reason,
disabled_reason: commenting_disabled_reason,
Expand Down
12 changes: 9 additions & 3 deletions back/app/services/permissions/phase_permissions_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ def denied_reason_for_action(action, reaction_mode: nil, delete_action: false)
phase_denied_reason = case action
when 'posting_idea'
posting_idea_denied_reason_for_action
when 'editing_idea'
editing_idea_denied_reason_for_action
when 'commenting_idea'
commenting_idea_denied_reason_for_action
when 'reacting_idea'
Expand All @@ -73,12 +75,10 @@ def denied_reason_for_action(action, reaction_mode: nil, delete_action: false)
when 'volunteering'
volunteering_denied_reason_for_phase
else
raise "Unsupported action: #{action}" unless SUPPORTED_ACTIONS.include?(action)
raise "Unsupported action: #{action}" if !supported_action? action
end
return phase_denied_reason if phase_denied_reason

return unless supported_action? action

super(action, scope: phase)
end

Expand All @@ -97,6 +97,12 @@ def posting_idea_denied_reason_for_action
end
end

def editing_idea_denied_reason_for_action
if !participation_method.supports_submission?
POSTING_DENIED_REASONS[:posting_not_supported] # TODO: Rename to sumbission_not_supported
end
end

def commenting_idea_denied_reason_for_action
if !participation_method.supports_commenting?
COMMENTING_DENIED_REASONS[:commenting_not_supported]
Expand Down
9 changes: 4 additions & 5 deletions back/app/services/permissions/project_permissions_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,6 @@ def action_descriptors
}
end

private

attr_reader :project

# Project methods
def project_visible_disabled_reason
user_can_moderate = user && UserRoleService.new.can_moderate?(project, user)
return if user_can_moderate
Expand All @@ -106,6 +101,10 @@ def project_visible_disabled_reason
end
end

private

attr_reader :project

def project_archived_disabled_reason
return unless project.admin_publication.archived?

Expand Down
2 changes: 2 additions & 0 deletions back/config/initializers/omniauth.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
end

# See https://github.com/omniauth/omniauth/wiki/Resolving-CVE-2015-9284
# TODO: Change all implementations to use POST requests
OmniAuth.config.allowed_request_methods = %i[post get]
OmniAuth.config.silence_get_warning = true

OmniAuth.config.full_host = lambda { |_env|
AppConfiguration.instance&.base_backend_uri
Expand Down
2 changes: 1 addition & 1 deletion back/db/structure.sql
Original file line number Diff line number Diff line change
Expand Up @@ -2122,7 +2122,7 @@ CREATE TABLE public.cosponsors_initiatives (
--

CREATE TABLE public.cosponsorships (
id uuid DEFAULT gen_random_uuid() NOT NULL,
id uuid DEFAULT shared_extensions.gen_random_uuid() NOT NULL,
status character varying DEFAULT 'pending'::character varying NOT NULL,
user_id uuid NOT NULL,
idea_id uuid NOT NULL,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# frozen_string_literal: true

require 'citizen_lab/mixins/feature_specification'

module IdKeycloak
module FeatureSpecification
extend CitizenLab::Mixins::FeatureSpecification

def self.feature_name
'keycloak_login'
end

def self.feature_title
'Keycloak (ID-Porten) Login'
end

def self.feature_description
'Allow users to authenticate with a Norwegian ID-Porten (via Keycloak) account.'
end

def self.allowed_by_default
false
end

def self.enabled_by_default
false
end
end
end
Loading
Loading