bpluser 0.4.0 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: bb1b456327994594e22bf36c97eb65c70095cf4c95defa9ec8915d9afb2a8e20
4
- data.tar.gz: d8d7903f634af553c0b902c542ef9c43adc4ccbf6bda371f012831272978cbf7
3
+ metadata.gz: cd649e2a92743c6ccfba60658937a9f8875e852fdb0d69ab4e492b3847c0da0c
4
+ data.tar.gz: cb75d8272d9c0a349420742b3387b6a0c9c34a4543dc506da9ce15cf6b3a97cb
5
5
  SHA512:
6
- metadata.gz: c2ad70554b1d5600d55c18e993268815f8d7d51c0be534f1d4f46258bf69e13bf10650933f20eb0b354f1f19bbf00163e1b7e62b91af664007c5bb8e38692f29
7
- data.tar.gz: 87e39affb5d1600ed387f33a03a6f6256613063f12be5988bdfa273958dbe16056f076d004b4bdaa1219b88ff1056ebe4a7f6039f8a3d97c5db2ffda2da2531f
6
+ metadata.gz: e0f409d0f76f047bd5183e70efdea64a82b13a8c3f34cf5bf70531985fc8794a3fe0fce0c663e7aa6f9b03af759c356ba0d218f9c68b1fe9f6269ca4af318fd8
7
+ data.tar.gz: fe4199c4dcb0a8f152697d878924237968004e96490dcc47df0d793f00b97686aa02adb4c44040b03b134c095cd35fa2acbbe6a6fe0a0d79b757244d22ae064b
data/README.md CHANGED
@@ -14,7 +14,7 @@ This includes bookmarks (Blacklight default), custom folders, and saved searches
14
14
 
15
15
  To install, add the following to your Gemfile:
16
16
  ```ruby
17
- gem 'bpluser', '~> 0.1.0'
17
+ gem 'bpluser', '~> 0.5.0'
18
18
  # OR
19
19
  gem 'bpluser', git: 'https://github.com/boston-library/bpluser'
20
20
  ```
@@ -32,6 +32,25 @@ rails bpluser:install:update_migrations
32
32
 
33
33
  (Note that the installer will ask to overwrite your local `config/locales/devise.en.yml`).
34
34
 
35
+ ### Local development
36
+
37
+ In one console, start Solr from project root:
38
+ ```
39
+ $ solr_wrapper --config .solr_wrapper.yml
40
+ ```
41
+ In a second console, index the sample Solr documents (run from `./spec/dummy`):
42
+ ```
43
+ # Solr must be running
44
+ $ bundle exec rake bpluser:test_index:seed
45
+ ```
46
+ Run the migrations and start the app (in second console, run from `./spec/dummy`):
47
+ ```
48
+ bundle exec rake db:create
49
+ bundle exec rake db:migrate
50
+ rails s
51
+ # app should be accessible at 127.0.0.1:3000
52
+ ```
53
+
35
54
  ### Running tests
36
55
 
37
56
  Start Solr from project root:
@@ -10,14 +10,30 @@ module Bpluser
10
10
  end
11
11
 
12
12
  module InstanceMethods
13
- # POST /resource
13
+ # override #create from Devise::RegistrationsController to add verify_captcha and logic for error handling
14
+ # this is the best way to preserve and re-render any submitted params when verify_recaptcha fails
14
15
  def create
15
- if User.exists?(email: sign_up_params[:email])
16
- flash[:error] = "An account with that email (#{sign_up_params[:email]}) already exists. Please sign in or click the \"Forgot your password?\" link below."
17
- redirect_to new_user_session_path and return
18
- end
16
+ build_resource(sign_up_params)
17
+
18
+ resource.save if verify_recaptcha
19
19
 
20
- super
20
+ yield resource if block_given?
21
+ if resource.persisted?
22
+ if resource.active_for_authentication?
23
+ set_flash_message! :notice, :signed_up
24
+ sign_up(resource_name, resource)
25
+ respond_with resource, location: after_sign_up_path_for(resource)
26
+ else
27
+ set_flash_message! :notice, :"signed_up_but_#{resource.inactive_message}"
28
+ expire_data_after_sign_in!
29
+ respond_with resource, location: after_inactive_sign_up_path_for(resource)
30
+ end
31
+ else
32
+ resource.errors.add(:errors, message: t('devise.registrations.recaptcha_error')) unless verify_recaptcha
33
+ clean_up_passwords resource
34
+ set_minimum_password_length
35
+ respond_with resource
36
+ end
21
37
  end
22
38
 
23
39
  protected
@@ -34,6 +34,11 @@
34
34
  <%= f.password_field :password_confirmation, autocomplete: 'off', class: 'form-control' %>
35
35
  </div>
36
36
  </div>
37
+ <div class="form-group row">
38
+ <div class="offset-sm-2 col-sm-4">
39
+ <%= recaptcha_tags(id: 'registrations_recaptcha') %>
40
+ </div>
41
+ </div>
37
42
  <div class="form-group row">
38
43
  <div class="offset-sm-2 col-sm-4">
39
44
  <%= f.submit 'Sign up', class: 'btn btn-primary' %>
@@ -1,4 +1,4 @@
1
- <% @page_title = "{@folder.title}-#{application_name}" %>
1
+ <% @page_title = "#{@folder.title} - #{application_name}" %>
2
2
 
3
3
  <%= javascript_include_tag 'bpluser/folder_tools' %>
4
4
 
@@ -127,3 +127,7 @@ en:
127
127
 
128
128
  users:
129
129
  account_heading: 'My Account'
130
+
131
+ devise:
132
+ registrations:
133
+ recaptcha_error: ' - Please click the "I am not a robot" verification.'
@@ -1,5 +1,11 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ begin
4
+ require 'recaptcha'
5
+ rescue LoadError => e
6
+ puts "A Gem Dependency is Missing....#{e.message}"
7
+ end
8
+
3
9
  module Bpluser
4
10
  class Engine < ::Rails::Engine
5
11
  isolate_namespace Bpluser
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Bpluser
4
- VERSION = '0.4.0'
4
+ VERSION = '0.5.0'
5
5
  end
@@ -53,6 +53,10 @@ module Bpluser
53
53
  generate 'bpluser:controller'
54
54
  end
55
55
 
56
+ def add_initializers
57
+ template 'config/initializers/recaptcha.rb'
58
+ end
59
+
56
60
  def bundle_install
57
61
  Bundler.with_clean_env do
58
62
  run 'bundle install'
@@ -0,0 +1,6 @@
1
+ # frozen_string_literal: true
2
+
3
+ Recaptcha.configure do |config|
4
+ config.site_key = ENV.fetch('RECAPTCHA_SITE_KEY') { Rails.application.credentials[:recaptcha_site_key] }
5
+ config.secret_key = ENV.fetch('RECAPTCHA_SECRET_KEY') { Rails.application.credentials[:recaptcha_secret_key] }
6
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bpluser
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Boston Public Library Repository Services
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-03-11 00:00:00.000000000 Z
11
+ date: 2024-06-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: blacklight
@@ -108,6 +108,20 @@ dependencies:
108
108
  - - "~>"
109
109
  - !ruby/object:Gem::Version
110
110
  version: 6.1.7.4
111
+ - !ruby/object:Gem::Dependency
112
+ name: recaptcha
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - "~>"
116
+ - !ruby/object:Gem::Version
117
+ version: '5.12'
118
+ type: :runtime
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - "~>"
123
+ - !ruby/object:Gem::Version
124
+ version: '5.12'
111
125
  - !ruby/object:Gem::Dependency
112
126
  name: awesome_print
113
127
  requirement: !ruby/object:Gem::Requirement
@@ -266,6 +280,7 @@ files:
266
280
  - lib/generators/bpluser/devise_generator.rb
267
281
  - lib/generators/bpluser/install_generator.rb
268
282
  - lib/generators/bpluser/templates/config/initializers/devise.rb.bak
283
+ - lib/generators/bpluser/templates/config/initializers/recaptcha.rb
269
284
  - lib/generators/bpluser/templates/config/locales/devise.en.yml
270
285
  - lib/generators/bpluser/templates/config/omniauth-polaris.yml
271
286
  - lib/generators/bpluser/templates/models/user.rb
@@ -293,7 +308,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
293
308
  - !ruby/object:Gem::Version
294
309
  version: '0'
295
310
  requirements: []
296
- rubygems_version: 3.3.26
311
+ rubygems_version: 3.3.27
297
312
  signing_key:
298
313
  specification_version: 4
299
314
  summary: Shared user access gem for public front ends