bpluser 0.3.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: abdb48f9fc552414be7298fdc2b0cb6d4e2517bc87ef5f44ac2ef3e4a869ea2f
4
- data.tar.gz: 8a7ec2a43bd1badfc2ddf33ad767c7262fe39847c2cca5e7a1b18da452468ace
3
+ metadata.gz: cd649e2a92743c6ccfba60658937a9f8875e852fdb0d69ab4e492b3847c0da0c
4
+ data.tar.gz: cb75d8272d9c0a349420742b3387b6a0c9c34a4543dc506da9ce15cf6b3a97cb
5
5
  SHA512:
6
- metadata.gz: 1a22bd759304d114c0583c83b8ea2485b016cdccfbaad5061c5883de47c772b7a7f91efa92b0e3671915f4b322ebba7338e81ecde75222754c837aa940b42341
7
- data.tar.gz: 483c799849eeee668ccc22f6346e7e3cb20af481fc1a768eed79f1d5e8c6a7f5ea004111b774d415c92766f0bc20901b29e18928384b39dbe862286f81b40926
6
+ metadata.gz: e0f409d0f76f047bd5183e70efdea64a82b13a8c3f34cf5bf70531985fc8794a3fe0fce0c663e7aa6f9b03af759c356ba0d218f9c68b1fe9f6269ca4af318fd8
7
+ data.tar.gz: fe4199c4dcb0a8f152697d878924237968004e96490dcc47df0d793f00b97686aa02adb4c44040b03b134c095cd35fa2acbbe6a6fe0a0d79b757244d22ae064b
data/README.md CHANGED
@@ -8,13 +8,13 @@ Rails engine for providing Devise-based user models and functionality for digita
8
8
  This includes bookmarks (Blacklight default), custom folders, and saved searches.
9
9
 
10
10
  # Requirements
11
- - `ruby >= 2.6.10`
12
- - `rails ~> 6.0.6`
11
+ - `ruby >= 3.1, < 3.2`
12
+ - `rails ~> 6.1.7`
13
13
  - `postgres v12 or higher`
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
  ```
@@ -31,3 +31,42 @@ rails bpluser:install:update_migrations
31
31
  ```
32
32
 
33
33
  (Note that the installer will ask to overwrite your local `config/locales/devise.en.yml`).
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
+
54
+ ### Running tests
55
+
56
+ Start Solr from project root:
57
+ ```
58
+ $ solr_wrapper --config .solr_wrapper_test.yml
59
+ ```
60
+ Index the sample Solr documents (run from `./spec/dummy`):
61
+ ```
62
+ # Solr must be running
63
+ $ RAILS_ENV=test bundle exec rake bpluser:test_index:seed
64
+ ```
65
+ Run specs
66
+ ```
67
+ # run all tests
68
+ $ bundle exec rake spec
69
+
70
+ # run a single spec
71
+ $ bundle exec rake spec SPEC=./spec/models/some_model_spec.rb
72
+ ```
@@ -22,7 +22,7 @@ class BookmarksController < CatalogController
22
22
 
23
23
  if request.xhr?
24
24
  # success ? render(json: { bookmarks: { count: current_or_guest_user.bookmarks.count }}) : render(:text => "", :status => "500")
25
- success ? render(:update) : render(plain: '', status: '500')
25
+ success ? render(:update) : render(plain: '', status: :internal_server_error)
26
26
  else
27
27
  if @bookmarks.any? && success
28
28
  flash[:notice] = I18n.t('blacklight.bookmarks.add.success', count: @bookmarks.count)
@@ -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.3.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.3.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: 2023-08-22 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
@@ -283,17 +298,17 @@ required_ruby_version: !ruby/object:Gem::Requirement
283
298
  requirements:
284
299
  - - ">="
285
300
  - !ruby/object:Gem::Version
286
- version: 3.0.6
301
+ version: '3.1'
287
302
  - - "<"
288
303
  - !ruby/object:Gem::Version
289
- version: '3.1'
304
+ version: '3.2'
290
305
  required_rubygems_version: !ruby/object:Gem::Requirement
291
306
  requirements:
292
307
  - - ">="
293
308
  - !ruby/object:Gem::Version
294
309
  version: '0'
295
310
  requirements: []
296
- rubygems_version: 3.4.10
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