Skip to content

Commit 7298977

Browse files
Add hashcash in components controllers (#428)
* add hashcash hidden file in components controllers * Update app/controllers/concerns/decidim/decidim_awesome/needs_hashcash.rb Co-authored-by: Ivan Vergés <[email protected]> * add _login_modal partial to checksum * fix test of number of override files --------- Co-authored-by: Ivan Vergés <[email protected]>
1 parent b4c5003 commit 7298977

File tree

5 files changed

+13
-7
lines changed

5 files changed

+13
-7
lines changed

app/controllers/concerns/decidim/decidim_awesome/needs_hashcash.rb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,11 @@ def awesome_check_hashcash
3030

3131
# Dynamically configures the gem https://github.com/BaseSecrete/active_hashcash
3232
def set_hashcash_bits
33-
if controller_name == "sessions"
34-
ActiveHashcash.bits = awesome_hashcash_bits(:login)
35-
elsif controller_name == "registrations"
36-
ActiveHashcash.bits = awesome_hashcash_bits(:signup)
37-
end
33+
ActiveHashcash.bits = if controller_name == "registrations"
34+
awesome_hashcash_bits(:signup)
35+
else
36+
awesome_hashcash_bits(:login)
37+
end
3838
end
3939
end
4040
end
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<!-- insert_after "erb[loud]:contains('sign_up')" -->
2+
3+
<%= render partial: "decidim/decidim_awesome/hashcash/hidden_field", locals: { zone: :login } %>

lib/decidim/decidim_awesome/checksums.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ decidim-core:
3434
decidim-0.29.1: b30423406afd43bb9af2c98d59d43632
3535
/app/views/decidim/devise/sessions/new.html.erb:
3636
decidim-0.29.1: a8fe60cd10c1636822c252d5488a979d
37+
/app/views/decidim/shared/_login_modal.html.erb:
38+
decidim-0.29.1: 0d615603bb45f7b209032578dda9fc72
3739
decidim-proposals:
3840
/lib/decidim/proposals/proposal_serializer.rb:
3941
decidim-0.29.1: 58915ff3a7528463587d3762a93ff51b

lib/decidim/decidim_awesome/engine.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ class Engine < ::Rails::Engine
3030
# Add hashcash to signup and login
3131
Decidim::Devise::SessionsController.include(Decidim::DecidimAwesome::NeedsHashcash)
3232
Decidim::Devise::RegistrationsController.include(Decidim::DecidimAwesome::NeedsHashcash)
33+
Decidim::Components::BaseController.include(Decidim::DecidimAwesome::NeedsHashcash)
3334
end
3435
# Include additional helpers globally
3536
ActiveSupport.on_load(:action_view) { include Decidim::DecidimAwesome::AwesomeHelpers }

spec/lib/system_checker_spec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ module Decidim::DecidimAwesome
1616
expect(subject.overrides["decidim-admin"].files.length).to eq(1)
1717
end
1818

19-
it "has 13 modified files in core" do
20-
expect(subject.overrides["decidim-core"].files.length).to eq(15)
19+
it "has 16 modified files in core" do
20+
expect(subject.overrides["decidim-core"].files.length).to eq(16)
2121
end
2222

2323
it "has 18 modified files in proposals" do

0 commit comments

Comments
 (0)