bpluser 0.0.26 → 0.1.12

Sign up to get free protection for your applications and to get access to all the features.
Files changed (119) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +70 -0
  3. data/Gemfile +19 -0
  4. data/Rakefile +6 -7
  5. data/app/controllers/bpluser/api_controller.rb +2 -3
  6. data/app/controllers/bpluser/users/omniauth_callbacks_controller.rb +1 -5
  7. data/app/controllers/bpluser/users/registrations_controller.rb +3 -3
  8. data/app/models/bpluser/ability.rb +2 -2
  9. data/app/models/bpluser/application_record.rb +5 -0
  10. data/app/models/bpluser/concerns/users.rb +190 -0
  11. data/app/models/bpluser/concerns/validatable.rb +47 -0
  12. data/app/models/bpluser/folder.rb +4 -6
  13. data/app/models/bpluser/folder_item.rb +3 -3
  14. data/app/models/bpluser/user_institution.rb +3 -3
  15. data/bin/rails +13 -0
  16. data/bin/rspec +29 -0
  17. data/bpluser.gemspec +38 -0
  18. data/lib/bpluser/engine.rb +1 -0
  19. data/lib/bpluser/version.rb +1 -1
  20. data/lib/bpluser.rb +12 -2
  21. data/lib/generators/bpluser/templates/models/user.rb +2 -6
  22. data/lib/tasks/bpluser_tasks.rake +1 -1
  23. data/spec/dummy/.ruby-version +1 -0
  24. data/{test → spec}/dummy/Rakefile +2 -3
  25. data/spec/dummy/app/assets/config/manifest.js +4 -0
  26. data/{app/controllers/bpluser/registrations_controller.rb → spec/dummy/app/assets/images/.keep} +0 -0
  27. data/spec/dummy/app/assets/javascripts/application.js +15 -0
  28. data/spec/dummy/app/assets/javascripts/cable.js +13 -0
  29. data/{test/dummy/public/favicon.ico → spec/dummy/app/assets/javascripts/channels/.keep} +0 -0
  30. data/spec/dummy/app/assets/stylesheets/application.css +15 -0
  31. data/spec/dummy/app/channels/application_cable/channel.rb +4 -0
  32. data/spec/dummy/app/channels/application_cable/connection.rb +4 -0
  33. data/{test → spec}/dummy/app/controllers/application_controller.rb +0 -1
  34. data/spec/dummy/app/controllers/concerns/.keep +0 -0
  35. data/{test → spec}/dummy/app/helpers/application_helper.rb +0 -0
  36. data/spec/dummy/app/jobs/application_job.rb +2 -0
  37. data/spec/dummy/app/mailers/application_mailer.rb +4 -0
  38. data/spec/dummy/app/models/application_record.rb +3 -0
  39. data/spec/dummy/app/models/concerns/.keep +0 -0
  40. data/spec/dummy/app/models/user.rb +3 -0
  41. data/spec/dummy/app/views/layouts/application.html.erb +15 -0
  42. data/spec/dummy/app/views/layouts/mailer.html.erb +13 -0
  43. data/spec/dummy/app/views/layouts/mailer.text.erb +1 -0
  44. data/spec/dummy/bin/bundle +3 -0
  45. data/spec/dummy/bin/rails +4 -0
  46. data/spec/dummy/bin/rake +4 -0
  47. data/spec/dummy/bin/setup +36 -0
  48. data/spec/dummy/bin/update +31 -0
  49. data/spec/dummy/bin/yarn +11 -0
  50. data/spec/dummy/config/application.rb +29 -0
  51. data/spec/dummy/config/boot.rb +5 -0
  52. data/spec/dummy/config/cable.yml +10 -0
  53. data/spec/dummy/config/environment.rb +5 -0
  54. data/spec/dummy/config/environments/development.rb +61 -0
  55. data/spec/dummy/config/environments/production.rb +94 -0
  56. data/spec/dummy/config/environments/test.rb +46 -0
  57. data/spec/dummy/config/initializers/application_controller_renderer.rb +8 -0
  58. data/spec/dummy/config/initializers/assets.rb +14 -0
  59. data/{test → spec}/dummy/config/initializers/backtrace_silencers.rb +0 -0
  60. data/spec/dummy/config/initializers/content_security_policy.rb +25 -0
  61. data/spec/dummy/config/initializers/cookies_serializer.rb +5 -0
  62. data/spec/dummy/config/initializers/devise.rb +290 -0
  63. data/spec/dummy/config/initializers/filter_parameter_logging.rb +4 -0
  64. data/{test → spec}/dummy/config/initializers/inflections.rb +6 -5
  65. data/{test → spec}/dummy/config/initializers/mime_types.rb +0 -1
  66. data/{test → spec}/dummy/config/initializers/wrap_parameters.rb +5 -5
  67. data/spec/dummy/config/locales/devise.en.yml +64 -0
  68. data/spec/dummy/config/locales/en.yml +33 -0
  69. data/spec/dummy/config/puma.rb +34 -0
  70. data/{test → spec}/dummy/config/routes.rb +0 -1
  71. data/spec/dummy/config/spring.rb +6 -0
  72. data/spec/dummy/config/storage.yml +34 -0
  73. data/spec/dummy/config.ru +5 -0
  74. data/spec/dummy/db/migrate/20181231191301_create_users.rb +41 -0
  75. data/spec/dummy/db/schema.rb +39 -0
  76. data/spec/dummy/lib/assets/.keep +0 -0
  77. data/spec/dummy/log/.keep +0 -0
  78. data/spec/dummy/package.json +5 -0
  79. data/spec/dummy/public/404.html +67 -0
  80. data/spec/dummy/public/422.html +67 -0
  81. data/spec/dummy/public/500.html +66 -0
  82. data/spec/dummy/public/apple-touch-icon-precomposed.png +0 -0
  83. data/spec/dummy/public/apple-touch-icon.png +0 -0
  84. data/spec/dummy/public/favicon.ico +0 -0
  85. data/spec/dummy/spec/models/user_spec.rb +5 -0
  86. data/spec/dummy/storage/.keep +0 -0
  87. data/spec/dummy/tmp/.keep +0 -0
  88. data/spec/dummy/tmp/storage/.keep +0 -0
  89. data/spec/rails_helper.rb +61 -0
  90. data/spec/spec_helper.rb +96 -0
  91. metadata +290 -95
  92. data/app/assets/javascripts/bpluser/application.js +0 -15
  93. data/app/assets/stylesheets/bpluser/application.css +0 -13
  94. data/app/controllers/bpluser/application_controller.rb +0 -4
  95. data/app/helpers/bpluser/application_helper.rb +0 -4
  96. data/app/models/bpluser/user.rb +0 -213
  97. data/app/models/bpluser/validatable.rb +0 -63
  98. data/app/views/layouts/bpluser/application.html.erb +0 -14
  99. data/test/bpluser_test.rb +0 -7
  100. data/test/dummy/README.rdoc +0 -261
  101. data/test/dummy/app/assets/javascripts/application.js +0 -15
  102. data/test/dummy/app/assets/stylesheets/application.css +0 -13
  103. data/test/dummy/app/views/layouts/application.html.erb +0 -14
  104. data/test/dummy/config/application.rb +0 -59
  105. data/test/dummy/config/boot.rb +0 -10
  106. data/test/dummy/config/environment.rb +0 -5
  107. data/test/dummy/config/environments/development.rb +0 -37
  108. data/test/dummy/config/environments/production.rb +0 -67
  109. data/test/dummy/config/environments/test.rb +0 -37
  110. data/test/dummy/config/initializers/secret_token.rb +0 -7
  111. data/test/dummy/config/initializers/session_store.rb +0 -8
  112. data/test/dummy/config/locales/en.yml +0 -5
  113. data/test/dummy/config.ru +0 -4
  114. data/test/dummy/public/404.html +0 -26
  115. data/test/dummy/public/422.html +0 -26
  116. data/test/dummy/public/500.html +0 -25
  117. data/test/dummy/script/rails +0 -6
  118. data/test/integration/navigation_test.rb +0 -10
  119. data/test/test_helper.rb +0 -15
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7f2736b79e16012f1fe5260a9394007435b8de59
4
- data.tar.gz: 596b8419d24719160f6a32e1b829ac91ca24e6b3
3
+ metadata.gz: 04206bee183f4ca5010dd71a07eab672510d0098
4
+ data.tar.gz: 4b8bce44344445856fdb59f1f594b2efeb4e209d
5
5
  SHA512:
6
- metadata.gz: bcddf94ebff73f14573d001e2996f33e2b5a7f968e9ba0673f975dce5d0e007b911a86950204fd40a89d421eef20600dd3d674926634e0fe0b93259e2b5e1d04
7
- data.tar.gz: 00ad7498d128642772df76654d90dc0dd28f0c3af6d32584be643c949147b67fbe3a3622c992c83c6bc3ee9754c641b0ae3f474366810fb68870c0be2126ba7a
6
+ metadata.gz: 6ec00eb6a9c8c925066994f37ebc76de27361d74e53db06cd959d4d95557fdfab40a149c7fe480a86138360b2e3fa4b205728ea61bdfe20821e5f2e4eb160592
7
+ data.tar.gz: 253907c67704b55ced0a3ae28060e5c1271e33f04850e3ce751b67bf68c333a9cb74e224a870fc71c847797c7dc7d4ce891098d51bbd359a3b1fba8a5a52f7ec
data/.gitignore ADDED
@@ -0,0 +1,70 @@
1
+ # Generated by default by Github #
2
+ ##################################
3
+ *.rbc
4
+ *.sassc
5
+ .sass-cache
6
+ capybara-*.html
7
+ .rspec
8
+ /.bundle
9
+ /vendor/bundle
10
+ /log/*
11
+ /tmp/*
12
+ /db/*.sqlite3
13
+ /public/system/*
14
+ /coverage/
15
+ /spec/tmp/*
16
+ **.orig
17
+ rerun.txt
18
+ pickle-email-*.html
19
+
20
+ # Specific configuration files #
21
+ ################################
22
+ database.yml
23
+ fedora.yml
24
+ solr.yml
25
+ role_map_cucumber.yml
26
+ role_map_development.yml
27
+ role_map_production.yml
28
+ role_map_test.yml
29
+ ark.yml
30
+ bpl_config.yml
31
+
32
+ # Files to ignore by default in Git #
33
+ #####################################
34
+ *.pdf
35
+ *.db
36
+ *.jar
37
+ *.gz
38
+ *.tar
39
+ *.zip
40
+ *.dll
41
+ *.sqlite
42
+ *.sql
43
+ *.sqlite3
44
+ *.log
45
+ # Specific Files to ignore #
46
+ ############################
47
+ Thumbs.db
48
+ Icon?
49
+ .DS_Store?
50
+ .DS_Store
51
+ ehthumbs.db
52
+ .idea # Rubymine config files
53
+ /.idea/*
54
+ Gemfile.lock
55
+
56
+ # Directories to ignore #
57
+ #########################
58
+ /public/data/*
59
+ /public/batch_uploads/*
60
+ /jetty/*
61
+ /solr_conf/*
62
+ /fedora_conf/*
63
+ /hydra-jetty/*
64
+ /*jetty*
65
+ /pkg/*
66
+
67
+ # Ignore edited Linux files #
68
+ #############################
69
+
70
+ *~
data/Gemfile ADDED
@@ -0,0 +1,19 @@
1
+ source "https://rubygems.org"
2
+
3
+ # Declare your gem's dependencies in bpluser.gemspec.
4
+ # Bundler will treat runtime dependencies like base dependencies, and
5
+ # development dependencies will be added by default to the :development group.
6
+ gemspec
7
+ gem 'bootsnap', require: false
8
+ # jquery-rails is used by the dummy application
9
+ group :development, :test do
10
+ gem "jquery-rails"
11
+ end
12
+
13
+ # Declare any dependencies that are still in development here instead of in
14
+ # your gemspec. These might include edge Rails or gems from your path or
15
+ # Git. Remember to move these dependencies to your gemspec before releasing
16
+ # your gem to rubygems.org.
17
+
18
+ # To use debugger
19
+ # gem 'debugger'
data/Rakefile CHANGED
@@ -1,16 +1,15 @@
1
- # encoding: UTF-8
2
- require 'rubygems'
3
1
  begin
4
2
  require 'bundler/setup'
5
3
  rescue LoadError
6
4
  puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
7
5
  end
8
6
 
9
- require 'rake'
10
- Bundler::GemHelper.install_tasks
11
-
7
+ APP_RAKEFILE = File.expand_path("spec/dummy/Rakefile", __dir__)
12
8
  # load rake tasks defined in lib/tasks that are not loaded in lib/active_fedora.rb
13
- load "tasks/bpluser_tasks.rake"
9
+ Dir['lib/tasks/*.rake'].each { |rake| load rake }
10
+
11
+ load 'rails/tasks/engine.rake'
14
12
 
13
+ load 'rails/tasks/statistics.rake'
15
14
 
16
- task :default => :test
15
+ task :default => [:spec]
@@ -2,8 +2,7 @@ module Bpluser
2
2
  class APIController < ActionController::Base
3
3
 
4
4
  def sdf
5
- JSON.parse(request.body.read)
6
-
5
+ JSON.parse(request.body.read) #What does this do?
7
6
  end
8
7
  end
9
- end
8
+ end
@@ -32,10 +32,6 @@ module Bpluser::Users::OmniauthCallbacksController
32
32
  end
33
33
  end
34
34
 
35
- def password
36
- puts "here in local authentication!"
37
- end
38
-
39
35
  def facebook
40
36
  # You need to implement the method below in your model (e.g. app/models/user.rb)
41
37
  @user = User.find_for_facebook_oauth(request.env["omniauth.auth"], current_user)
@@ -49,4 +45,4 @@ module Bpluser::Users::OmniauthCallbacksController
49
45
  end
50
46
  end
51
47
  end
52
- end
48
+ end
@@ -1,7 +1,8 @@
1
1
  module Bpluser::Users::RegistrationsController
2
+ #TODO Make this an actual controller
2
3
  #< Devise::RegistrationsController
3
4
  def self.included(base)
4
- base.send :before_filter, :update_sanitized_params, :if => :devise_controller?
5
+ base.send :before_action, :update_sanitized_params, :if => :devise_controller?
5
6
  base.send :include, InstanceMethods
6
7
  end
7
8
 
@@ -18,7 +19,7 @@ module Bpluser::Users::RegistrationsController
18
19
  params[:user][:uid] = params[:user][:email]
19
20
  params[:user][:username] = params[:user][:uid]
20
21
  params[:user][:display_name] = params[:user][:first_name] + " " + params[:user][:last_name]
21
- if User.where(:provider => params[:user][:provider], :uid => params[:user][:email]).present?
22
+ if User.where(:provider => params[:user][:provider], :uid => params[:user][:email]).exists?
22
23
  flash[:error] = "An account with that email (#{params[:user][:email]}) already exists. Please sign in or click the \"Forgot your password?\" link below."
23
24
  redirect_to new_user_session_path
24
25
  else
@@ -30,6 +31,5 @@ module Bpluser::Users::RegistrationsController
30
31
  def resource_params
31
32
  params.require(:user).permit(:username, :email, :first_name, :last_name, :provider, :display_name, :password, :password_confirmation, :uid)
32
33
  end
33
-
34
34
  end
35
35
  end
@@ -1,5 +1,5 @@
1
1
  module Bpluser::Ability
2
-
2
+ #TODO Move this into concern
3
3
  def self.included(base)
4
4
  base.send :include, InstanceMethods
5
5
  end
@@ -19,4 +19,4 @@ module Bpluser::Ability
19
19
  end
20
20
  end
21
21
 
22
- end
22
+ end
@@ -0,0 +1,5 @@
1
+ module Bpluser
2
+ class ApplicationRecord < ActiveRecord::Base
3
+ self.abstract_class = true
4
+ end
5
+ end
@@ -0,0 +1,190 @@
1
+ module Bpluser
2
+ module Concerns
3
+ module Users
4
+ #Changed this to a concern so the modules can resolve better
5
+ extend ActiveSupport::Concern
6
+ include Validatable
7
+ #included
8
+ included do
9
+ devise :database_authenticatable, :registerable, :recoverable, :rememberable, :trackable, :omniauthable, :omniauth_providers => [:ldap, :polaris, :facebook]
10
+
11
+ has_many :user_institutions, inverse_of: :user, dependent: :destroy, :class_name => "Bpluser::UserInstitution"
12
+
13
+ has_many :folders, inverse_of: :user, :dependent => :destroy, :class_name => "Bpluser::Folder"
14
+ has_many :folder_items, through: :folders, class_name: "Bpluser::FolderItem"
15
+
16
+ #BEGIN INSTANCE METHODS
17
+ def to_s
18
+ self.name
19
+ end
20
+
21
+ def name
22
+ return self.username rescue self.display_name.try(:titleize)
23
+ end
24
+
25
+ def user_key
26
+ send(Devise.authentication_keys.first)
27
+ end
28
+
29
+
30
+ def ldap_groups
31
+ #Hydra::LDAP.groups_for_user(username + ",dc=psu,dc=edu")
32
+ #['archivist', 'admin_policy_object_editor']
33
+
34
+ Hydra::LDAP.groups_for_user(Net::LDAP::Filter.eq('samaccountname', self.username), ['memberOf']) { |result| result.first[:memberOf].select{ |y| y.starts_with? 'CN=' }.map{ |x| x.sub(/^CN=/, '').sub(/,OU=Private Groups,DC=private,DC=bpl,DC=org/, '').sub(/,OU=Distribution Lists/, '').sub(/,OU=Security Groups/, '') } } rescue []
35
+ end
36
+
37
+ def populate_attributes
38
+ end
39
+
40
+ def default_user_groups
41
+ # # everyone is automatically a member of the group 'public'
42
+ #['public', 'test']
43
+ end
44
+
45
+ def get_uploads_collection
46
+ query="rightsMetadata_edit_access_machine_person_t:#{uid} AND title_s:Uploads AND has_model_s:info\\:fedora/afmodel\\:DILCollection"
47
+ ActiveFedora::SolrService.query(query, {:fl=>'id title_t'})
48
+ end
49
+
50
+ def get_details_collection
51
+ query="rightsMetadata_edit_access_machine_person_t:#{uid} AND title_s:Details AND has_model_s:info\\:fedora/afmodel\\:DILCollection"
52
+ ActiveFedora::SolrService.query(query, {:fl=>'id title_t'})
53
+ end
54
+
55
+ def collections
56
+ query="rightsMetadata_edit_access_machine_person_t:#{uid} AND NOT title_t:Uploads AND NOT title_t:Details AND has_model_s:info\\:fedora/afmodel\\:DILCollection"
57
+ ActiveFedora::SolrService.query(query, {:fl=>'id title_t'})
58
+ end
59
+
60
+ def existing_folder_item_for (document_id)
61
+ self.get_folder_item(document_id)
62
+ end
63
+
64
+ def get_folder_item (document_id)
65
+ self.folder_items.where(document_id: document_id).first if self.folder_items.where(document_id: document_id).exists?
66
+ end
67
+
68
+ def superuser?
69
+ roles.where(name: 'superuser').exists?
70
+ end
71
+
72
+ def permanent_account?
73
+ self.provider != 'digital_stacks_temporary'
74
+ end
75
+
76
+ def email_not_required?
77
+ self.provider != 'digital_stacks_temporary' and self.provider != 'polaris'
78
+ end
79
+ #END INSTANCE METHODS
80
+ end
81
+
82
+
83
+
84
+
85
+ #BEGIN CLASS METHODS
86
+ class_methods do
87
+ def find_for_ldap_oauth(auth_response, signed_in_resource=nil)
88
+
89
+ ldap_raw_details = auth_response[:extra][:raw_info]
90
+ ldap_info_details = auth_response[:info]
91
+
92
+ user = User.where(:provider => auth_response.provider, :uid => ldap_raw_details.samaccountname[0].downcase).first
93
+
94
+ #first_name:ldap_info_details.first_name,
95
+ #last_name:ldap_info_details.last_name,
96
+ unless user
97
+ user = User.create(provider:auth_response.provider,
98
+ uid:ldap_raw_details.samaccountname[0].downcase,
99
+ username:ldap_raw_details.samaccountname[0].downcase,
100
+ email:ldap_raw_details.mail[0].to_s.downcase,
101
+ password:Devise.friendly_token[0,20],
102
+ display_name: ldap_info_details.first_name + " " + ldap_info_details.last_name,
103
+ first_name: ldap_info_details.first_name,
104
+ last_name: ldap_info_details.last_name
105
+ )
106
+ end
107
+ groups = user.ldap_groups
108
+ groups.each do |group|
109
+ if(group == "Repository Administrators")
110
+ superuser_role = Role.where(:name=>'superuser').first
111
+ if(superuser_role == nil)
112
+ superuser_role = Role.create(:name=>"superuser")
113
+ end
114
+ user.roles << superuser_role unless user.roles.include?(superuser_role)
115
+ user.save!
116
+
117
+ admin_role = Role.where(:name=>'admin').first
118
+ if(admin_role == nil)
119
+ admin_role = Role.create(:name=>"admin")
120
+ end
121
+ user.roles << admin_role unless user.roles.include?(admin_role)
122
+ user.save!
123
+ end
124
+ end
125
+ user
126
+ end
127
+
128
+ def find_for_polaris_oauth(auth_response, signed_in_resource=nil)
129
+ polaris_raw_details = auth_response[:extra][:raw_info]
130
+ polaris_info_details = auth_response[:info]
131
+
132
+ user = User.where(:provider => auth_response.provider, :uid => auth_response[:uid]).first
133
+
134
+ #first_name:ldap_info_details.first_name,
135
+ #last_name:ldap_info_details.last_name,
136
+ unless user
137
+ email_value = polaris_info_details[:email].present? ? polaris_info_details[:email] : ''
138
+ #For some reason, User.create has no id set despite that intending to be autocreated. Unsure what is up with that. So trying this.
139
+ user = User.new(provider:auth_response.provider,
140
+ uid:auth_response[:uid],
141
+ username:polaris_info_details[:first_name],
142
+ email:email_value,
143
+ password:Devise.friendly_token[0,20],
144
+ display_name:polaris_info_details[:first_name] + " " + polaris_info_details[:last_name],
145
+ first_name: polaris_info_details[:first_name],
146
+ last_name: polaris_info_details[:last_name]
147
+
148
+ )
149
+ user.save!
150
+
151
+ end
152
+ user
153
+ end
154
+
155
+ def find_for_facebook_oauth(auth, signed_in_resource=nil)
156
+ user = User.where(:provider => auth.provider, :uid => auth.uid).first
157
+ unless user
158
+ user = User.create(display_name:auth.extra.raw_info.name,
159
+ uid:auth.uid,
160
+ provider:auth.provider,
161
+ username:auth.info.nickname,
162
+ email:auth.info.email,
163
+ password:Devise.friendly_token[0,20] ,
164
+ first_name:auth.extra.raw_info.first_name,
165
+ last_name:auth.extra.raw_info.last_name
166
+ )
167
+ end
168
+ user
169
+ end
170
+
171
+ def find_for_local_auth(auth, signed_in_resource=nil)
172
+ user = User.where(:provider => auth.provider, :uid => auth.uid).first
173
+ unless user
174
+ user = User.create(display_name:auth.full_name,
175
+ uid:auth.uid,
176
+ provider:auth.provider,
177
+ username:auth.uid,
178
+ email:auth.email,
179
+ password:auth.password,
180
+ first_name:auth.first_name,
181
+ last_name:auth.last_name
182
+ )
183
+ end
184
+ user
185
+ end
186
+ end
187
+ #END CLASS METHODS
188
+ end
189
+ end
190
+ end
@@ -0,0 +1,47 @@
1
+ module Bpluser
2
+ module Concerns
3
+ module Validatable
4
+ extend ActiveSupport::Concern
5
+ VALIDATIONS = %i(validates_presence_of validates_format_of validates_confirmation_of validates_length_of).freeze
6
+ #BEGIN INCLUDED
7
+ included do
8
+ validates_presence_of :email, if: [:email_required?, :email_not_required?]
9
+ #validates_uniqueness_of :email, allow_blank: true, if: :email_changed?
10
+ validates_format_of :email, with: email_regexp, allow_blank: true, if: [:email_changed?, :email_not_required?]
11
+
12
+ validates_presence_of :password, if: :password_required?
13
+ validates_confirmation_of :password, if: :password_required?
14
+ validates_length_of :password, within: password_length, allow_blank: true
15
+
16
+ #INSTANCE METHODS
17
+ protected
18
+ def password_required?
19
+ !persisted? || !password.nil? || !password_confirmation.nil?
20
+ end
21
+
22
+ def email_required?
23
+ true
24
+ end
25
+ end
26
+ #END INCLUDED
27
+
28
+ #BEGIN CLASS METHODS
29
+ class_methods do
30
+ ::Devise::Models.config(self, :email_regexp, :password_length)
31
+
32
+ def required_fields(klass)
33
+ []
34
+ end
35
+
36
+ # def assert_validations_api!(base) #:nodoc:
37
+ # unavailable_validations = VALIDATIONS.select { |v| !base.respond_to?(v) }
38
+ #
39
+ # unless unavailable_validations.empty?
40
+ # raise "Could not use :validatable module since #{base} does not respond " <<
41
+ # "to the following methods: #{unavailable_validations.to_sentence}."
42
+ # end
43
+ # end
44
+ end
45
+ end
46
+ end
47
+ end
@@ -1,8 +1,8 @@
1
1
  module Bpluser
2
- class Folder < ActiveRecord::Base
2
+ class Folder < ApplicationRecord
3
3
 
4
- belongs_to :user, polymorphic: true
5
- has_many :folder_items, :dependent => :destroy, :class_name => "Bpluser::FolderItem"
4
+ belongs_to :user, inverse_of: :folders, class_name: "::User"
5
+ has_many :folder_items, inverse_of: :folder ,:dependent => :destroy, :class_name => "Bpluser::FolderItem"
6
6
 
7
7
  validates :user_id, :presence => true
8
8
  #validates :title, :presence => true, :length => {:maximum => 40}
@@ -13,9 +13,7 @@ module Bpluser
13
13
  #attr_accessible :id, :title, :description, :visibility
14
14
 
15
15
  def has_folder_item (document_id)
16
- self.folder_items.find do |fldr_itm|
17
- return fldr_itm if fldr_itm.document_id == document_id
18
- end
16
+ self.folder_items.where(document_id: document_id) if self.folder_items.where(document_id: document_id).exists?
19
17
  end
20
18
 
21
19
  end
@@ -1,8 +1,8 @@
1
1
  module Bpluser
2
- class FolderItem < ActiveRecord::Base
2
+ class FolderItem < ApplicationRecord
3
3
  #attr_accessible :document_id
4
4
 
5
- belongs_to :folder, :class_name => "Bpluser::Folder"
5
+ belongs_to :folder, inverse_of: :folder_items, :class_name => "Bpluser::Folder"
6
6
 
7
7
  validates :folder_id, :presence => true
8
8
  validates :document_id, :presence => true
@@ -12,4 +12,4 @@ module Bpluser
12
12
  end
13
13
 
14
14
  end
15
- end
15
+ end
@@ -1,6 +1,6 @@
1
1
  module Bpluser
2
- class UserInstitution < ActiveRecord::Base
2
+ class UserInstitution < ApplicationRecord
3
3
  self.table_name = "user_institutions"
4
- belongs_to :user
4
+ belongs_to :user, inverse_of: :user_institutions
5
5
  end
6
- end
6
+ end
data/bin/rails ADDED
@@ -0,0 +1,13 @@
1
+ #!/usr/bin/env ruby
2
+ # This command will automatically be run when you run "rails" with Rails gems
3
+ # installed from the root of your application.
4
+
5
+ ENGINE_ROOT = File.expand_path('..', __dir__)
6
+ ENGINE_PATH = File.expand_path('../lib/bpluser/engine', __dir__)
7
+ APP_PATH = File.expand_path('../spec/dummy/config/application', __dir__)
8
+ # Set up gems listed in the Gemfile.
9
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__)
10
+ require 'bundler/setup' if File.exist?(ENV['BUNDLE_GEMFILE'])
11
+
12
+ require 'rails/all'
13
+ require 'rails/engine/commands'
data/bin/rspec ADDED
@@ -0,0 +1,29 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ #
5
+ # This file was generated by Bundler.
6
+ #
7
+ # The application 'rspec' is installed as part of a gem, and
8
+ # this file is here to facilitate running it.
9
+ #
10
+
11
+ require "pathname"
12
+ ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
13
+ Pathname.new(__FILE__).realpath)
14
+
15
+ bundle_binstub = File.expand_path("../bundle", __FILE__)
16
+
17
+ if File.file?(bundle_binstub)
18
+ if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
19
+ load(bundle_binstub)
20
+ else
21
+ abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
22
+ Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
23
+ end
24
+ end
25
+
26
+ require "rubygems"
27
+ require "bundler/setup"
28
+
29
+ load Gem.bin_path("rspec-core", "rspec")
data/bpluser.gemspec ADDED
@@ -0,0 +1,38 @@
1
+ $:.push File.expand_path("../lib", __FILE__)
2
+
3
+ # Maintain your gem's version:
4
+ require "bpluser/version"
5
+
6
+ # Describe your gem and declare its dependencies:
7
+ Gem::Specification.new do |s|
8
+ s.name = "bpluser"
9
+ s.version = Bpluser::VERSION
10
+ s.authors = ["Boston Public Library Web Services"]
11
+ s.email = ['sanderson@bpl.org', 'bbarber@bpl.org' ]
12
+ s.homepage = "http://www.bpl.org"
13
+ s.summary = "Shared user access gem of BPL"
14
+ s.description = "Shared user access gem of BPL"
15
+
16
+ s.files = `git ls-files -z`.split("\x0")
17
+ s.executables = s.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ s.test_files = s.files.grep(%r{^(test|spec|features)/})
19
+
20
+ s.required_ruby_version = '~> 2.4'
21
+
22
+ s.add_dependency "rails", '>= 5', '< 6'
23
+ s.add_dependency "omniauth", '~> 1.8.1', '< 1.9.0'
24
+ s.add_dependency "omniauth-ldap", '2.0.0'
25
+ s.add_dependency "omniauth-facebook", '5.0.0'
26
+ s.add_dependency "hydra-role-management", '1.0.0'
27
+ s.add_dependency 'devise', '4.5.0'
28
+ s.add_dependency 'devise-guests', '0.6.1'
29
+ s.add_dependency 'omniauth-polaris', '1.0.5'
30
+
31
+ s.add_development_dependency 'bundler', '>= 1.3.0'
32
+ s.add_development_dependency 'rake'
33
+ s.add_development_dependency 'active-fedora', '>= 8.0.1', '< 9'
34
+ s.add_development_dependency 'hydra-ldap', '0.1.0'
35
+ s.add_development_dependency 'rspec-rails', '~> 3.8'
36
+ s.add_development_dependency 'awesome_print'
37
+ s.add_development_dependency "sqlite3"
38
+ end
@@ -1,3 +1,4 @@
1
+ require 'devise'
1
2
  module Bpluser
2
3
  class Engine < ::Rails::Engine
3
4
  isolate_namespace Bpluser
@@ -1,3 +1,3 @@
1
1
  module Bpluser
2
- VERSION = "0.0.26"
2
+ VERSION = "0.1.12".freeze
3
3
  end
data/lib/bpluser.rb CHANGED
@@ -1,5 +1,15 @@
1
- require "bpluser/engine"
2
-
1
+ begin
2
+ require 'base64'
3
+ require 'cgi'
4
+ require 'openssl'
5
+ require 'rest_client'
6
+ require 'active_support/concern' unless defined? ActiveSupport::Concern
7
+ require 'active_fedora' unless defined? ActiveFedora
8
+ require 'hydra-ldap' unless defined? Hydra::LDAP
9
+ rescue LoadError => e
10
+ raise "One more more depndencies have not been installed please install the gem referred to in this error #{e.message}"
11
+ end
12
+ require 'bpluser/engine'
3
13
  module Bpluser
4
14
  autoload :Routes, 'bpluser/routes'
5
15
 
@@ -1,14 +1,10 @@
1
- class User < ActiveRecord::Base
2
- require 'base64'
3
- require 'cgi'
4
- require 'openssl'
5
- require 'rest_client'
1
+ class User < ApplicationRecord
6
2
  # Connects this user object to Hydra behaviors.
7
3
  include Hydra::User
8
4
  # Connects this user object to Blacklights Bookmarks.
9
5
  include Blacklight::User
10
6
  # Connects this user object to the BPL omniauth service
11
- include Bpluser::User
7
+ include Bpluser::Concerns::User
12
8
  self.table_name = "users"
13
9
 
14
10
  end
@@ -3,7 +3,7 @@
3
3
  # # Task goes here
4
4
  # end
5
5
 
6
- APP_ROOT = File.expand_path("../..", __FILE__)
6
+ # APP_ROOT = File.expand_path("../..", __FILE__)
7
7
 
8
8
  namespace :bpluser do
9
9
 
@@ -0,0 +1 @@
1
+ 2.4.5
@@ -1,7 +1,6 @@
1
- #!/usr/bin/env rake
2
1
  # Add your own tasks in files placed in lib/tasks ending in .rake,
3
2
  # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
4
3
 
5
- require File.expand_path('../config/application', __FILE__)
4
+ require_relative 'config/application'
6
5
 
7
- Dummy::Application.load_tasks
6
+ Rails.application.load_tasks
@@ -0,0 +1,4 @@
1
+ //= link_tree ../images
2
+ //= link_directory ../javascripts .js
3
+ //= link_directory ../stylesheets .css
4
+ //= link my_plugin_manifest.js