samvera-persona 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/LICENSE +205 -0
- data/Rakefile +33 -0
- data/app/assets/config/samvera-persona_manifest.js +0 -0
- data/app/controllers/concerns/samvera/persona/avalon_auth.rb +20 -0
- data/app/controllers/concerns/samvera/persona/becomes_behavior.rb +10 -0
- data/app/controllers/samvera/persona/users_controller.rb +100 -0
- data/app/controllers/test_controller.rb +4 -0
- data/app/helpers/samvera/persona/application_helper.rb +13 -0
- data/app/models/concerns/samvera/persona/soft_delete_behavior.rb +10 -0
- data/app/models/concerns/samvera/persona/username_behavior.rb +26 -0
- data/app/presenters/samvera/persona/users_presenter.rb +41 -0
- data/app/views/avalon/samvera/persona/users/_form.html.erb +63 -0
- data/app/views/avalon/samvera/persona/users/_index_title.html.erb +1 -0
- data/app/views/avalon/samvera/persona/users/edit.html.erb +7 -0
- data/app/views/samvera/persona/users/_form.html.erb +25 -0
- data/app/views/samvera/persona/users/_index_title.html.erb +3 -0
- data/app/views/samvera/persona/users/edit.html.erb +29 -0
- data/app/views/samvera/persona/users/index.html.erb +96 -0
- data/app/views/samvera/persona/users/show.html.erb +33 -0
- data/app/views/test/index.html.erb +2 -0
- data/config/locales/hyrax.de.yml +37 -0
- data/config/locales/hyrax.en.yml +47 -0
- data/config/locales/hyrax.es.yml +37 -0
- data/config/locales/hyrax.fr.yml +37 -0
- data/config/locales/hyrax.it.yml +37 -0
- data/config/locales/hyrax.pt-BR.yml +37 -0
- data/config/locales/hyrax.zh.yml +37 -0
- data/config/routes.rb +10 -0
- data/db/migrate/20190520170817_add_deleted_at_to_users.rb +6 -0
- data/db/migrate/20190628003746_persona_devise_invitable_add_to_users.rb +25 -0
- data/lib/samvera-persona/engine.rb +53 -0
- data/lib/samvera-persona/version.rb +5 -0
- data/lib/samvera-persona.rb +11 -0
- data/lib/tasks/samvera-persona.rake +4 -0
- data/spec/controllers/samvera/persona/users_controller_spec.rb +72 -0
- data/spec/dummy/Rakefile +6 -0
- data/spec/dummy/app/assets/config/manifest.js +3 -0
- data/spec/dummy/app/assets/javascripts/application.js +15 -0
- data/spec/dummy/app/assets/javascripts/cable.js +13 -0
- data/spec/dummy/app/assets/stylesheets/application.css +15 -0
- data/spec/dummy/app/channels/application_cable/channel.rb +4 -0
- data/spec/dummy/app/channels/application_cable/connection.rb +4 -0
- data/spec/dummy/app/controllers/application_controller.rb +2 -0
- data/spec/dummy/app/helpers/application_helper.rb +2 -0
- data/spec/dummy/app/jobs/application_job.rb +2 -0
- data/spec/dummy/app/mailers/application_mailer.rb +4 -0
- data/spec/dummy/app/models/application_record.rb +3 -0
- data/spec/dummy/app/models/user.rb +31 -0
- data/spec/dummy/app/views/layouts/application.html.erb +15 -0
- data/spec/dummy/app/views/layouts/mailer.html.erb +13 -0
- data/spec/dummy/app/views/layouts/mailer.text.erb +1 -0
- data/spec/dummy/bin/bundle +3 -0
- data/spec/dummy/bin/rails +4 -0
- data/spec/dummy/bin/rake +4 -0
- data/spec/dummy/bin/setup +36 -0
- data/spec/dummy/bin/update +31 -0
- data/spec/dummy/bin/yarn +11 -0
- data/spec/dummy/config/application.rb +20 -0
- data/spec/dummy/config/boot.rb +5 -0
- data/spec/dummy/config/cable.yml +10 -0
- data/spec/dummy/config/database.yml +25 -0
- data/spec/dummy/config/environment.rb +5 -0
- data/spec/dummy/config/environments/development.rb +61 -0
- data/spec/dummy/config/environments/production.rb +94 -0
- data/spec/dummy/config/environments/test.rb +46 -0
- data/spec/dummy/config/initializers/application_controller_renderer.rb +8 -0
- data/spec/dummy/config/initializers/assets.rb +14 -0
- data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/dummy/config/initializers/content_security_policy.rb +25 -0
- data/spec/dummy/config/initializers/cookies_serializer.rb +5 -0
- data/spec/dummy/config/initializers/devise.rb +347 -0
- data/spec/dummy/config/initializers/filter_parameter_logging.rb +4 -0
- data/spec/dummy/config/initializers/inflections.rb +16 -0
- data/spec/dummy/config/initializers/mime_types.rb +4 -0
- data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/spec/dummy/config/locales/devise.en.yml +65 -0
- data/spec/dummy/config/locales/devise_invitable.en.yml +31 -0
- data/spec/dummy/config/locales/en.yml +33 -0
- data/spec/dummy/config/puma.rb +34 -0
- data/spec/dummy/config/routes.rb +6 -0
- data/spec/dummy/config/spring.rb +6 -0
- data/spec/dummy/config/storage.yml +34 -0
- data/spec/dummy/config.ru +5 -0
- data/spec/dummy/db/development.sqlite3 +0 -0
- data/spec/dummy/db/migrate/20190513181646_create_users_for_engine_testing.rb +9 -0
- data/spec/dummy/db/migrate/20190628003608_add_devise_to_users.rb +51 -0
- data/spec/dummy/db/schema.rb +41 -0
- data/spec/dummy/db/test.sqlite3 +0 -0
- data/spec/dummy/log/development.log +348 -0
- data/spec/dummy/log/test.log +16248 -0
- data/spec/dummy/package.json +5 -0
- data/spec/dummy/public/404.html +67 -0
- data/spec/dummy/public/422.html +67 -0
- data/spec/dummy/public/500.html +66 -0
- data/spec/dummy/public/apple-touch-icon-precomposed.png +0 -0
- data/spec/dummy/public/apple-touch-icon.png +0 -0
- data/spec/dummy/public/favicon.ico +0 -0
- data/spec/dummy/tmp/development_secret.txt +1 -0
- data/spec/factories/users.rb +21 -0
- data/spec/presenters/samvera/persona/users_presenter_spec.rb +42 -0
- data/spec/rails_helper.rb +3 -0
- data/spec/routing/admin_routes_spec.rb +8 -0
- data/spec/spec_helper.rb +17 -0
- data/spec/support/devise.rb +4 -0
- data/spec/support/factory_bot.rb +3 -0
- data/spec/views/samvera/persona/users/index.html.erb_spec.rb +53 -0
- metadata +363 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 0aa7c2fad1a3516b6b8bb4ecfc1f14776fa335e6eb65a5f887ec98715b87ffe6
|
4
|
+
data.tar.gz: 75329f5fdad449b9cdab5ea5670d977378b44c5ba1136963fd5a079a23ecc319
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 38e0864ea45f01aeae073ada221be4635dfc9119c233e1e1d54c971d352bcfb54fc01e033958d1778997474823978f10ad3c0960ac81467236e2915a8f652f42
|
7
|
+
data.tar.gz: 6088ba72b26cd6fee6995f86f95fd50a23a70bd8ccac0d3e702ebfafb47dad09657db73749c7f2b3e51913dae7b25c3a7c41aeeb7e840822a548addeb89e64ce
|
data/LICENSE
ADDED
@@ -0,0 +1,205 @@
|
|
1
|
+
Apache License
|
2
|
+
Version 2.0, January 2004
|
3
|
+
http://www.apache.org/licenses/
|
4
|
+
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
6
|
+
|
7
|
+
1. Definitions.
|
8
|
+
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
11
|
+
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
13
|
+
the copyright owner that is granting the License.
|
14
|
+
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
16
|
+
other entities that control, are controlled by, or are under common
|
17
|
+
control with that entity. For the purposes of this definition,
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
19
|
+
direction or management of such entity, whether by contract or
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
22
|
+
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
24
|
+
exercising permissions granted by this License.
|
25
|
+
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
27
|
+
including but not limited to software source code, documentation
|
28
|
+
source, and configuration files.
|
29
|
+
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
31
|
+
transformation or translation of a Source form, including but
|
32
|
+
not limited to compiled object code, generated documentation,
|
33
|
+
and conversions to other media types.
|
34
|
+
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
36
|
+
Object form, made available under the License, as indicated by a
|
37
|
+
copyright notice that is included in or attached to the work
|
38
|
+
(an example is provided in the Appendix below).
|
39
|
+
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
46
|
+
the Work and Derivative Works thereof.
|
47
|
+
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
49
|
+
the original version of the Work and any modifications or additions
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
61
|
+
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
64
|
+
subsequently incorporated within the Work.
|
65
|
+
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
72
|
+
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
78
|
+
where such license applies only to those patent claims licensable
|
79
|
+
by such Contributor that are necessarily infringed by their
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
82
|
+
institute patent litigation against any entity (including a
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
85
|
+
or contributory patent infringement, then any patent licenses
|
86
|
+
granted to You under this License for that Work shall terminate
|
87
|
+
as of the date such litigation is filed.
|
88
|
+
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
91
|
+
modifications, and in Source or Object form, provided that You
|
92
|
+
meet the following conditions:
|
93
|
+
|
94
|
+
(a) You must give any other recipients of the Work or
|
95
|
+
Derivative Works a copy of this License; and
|
96
|
+
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
98
|
+
stating that You changed the files; and
|
99
|
+
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
102
|
+
attribution notices from the Source form of the Work,
|
103
|
+
excluding those notices that do not pertain to any part of
|
104
|
+
the Derivative Works; and
|
105
|
+
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
108
|
+
include a readable copy of the attribution notices contained
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
111
|
+
of the following places: within a NOTICE text file distributed
|
112
|
+
as part of the Derivative Works; within the Source form or
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
114
|
+
within a display generated by the Derivative Works, if and
|
115
|
+
wherever such third-party notices normally appear. The contents
|
116
|
+
of the NOTICE file are for informational purposes only and
|
117
|
+
do not modify the License. You may add Your own attribution
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
120
|
+
that such additional attribution notices cannot be construed
|
121
|
+
as modifying the License.
|
122
|
+
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
124
|
+
may provide additional or different license terms and conditions
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
128
|
+
the conditions stated in this License.
|
129
|
+
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
133
|
+
this License, without any additional terms or conditions.
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
135
|
+
the terms of any separate license agreement you may have executed
|
136
|
+
with Licensor regarding such Contributions.
|
137
|
+
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
140
|
+
except as required for reasonable and customary use in describing the
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
142
|
+
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
152
|
+
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
158
|
+
incidental, or consequential damages of any character arising as a
|
159
|
+
result of this License or out of the use or inability to use the
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
162
|
+
other commercial damages or losses), even if such Contributor
|
163
|
+
has been advised of the possibility of such damages.
|
164
|
+
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
168
|
+
or other liability obligations and/or rights consistent with this
|
169
|
+
License. However, in accepting such obligations, You may act only
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
174
|
+
of your accepting any such warranty or additional liability.
|
175
|
+
|
176
|
+
END OF TERMS AND CONDITIONS
|
177
|
+
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
179
|
+
|
180
|
+
To apply the Apache License to your work, attach the following
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "{}"
|
182
|
+
replaced with your own identifying information. (Don't include
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
184
|
+
comment syntax for the file format. We also recommend that a
|
185
|
+
file or class name and description of purpose be included on the
|
186
|
+
same "printed page" as the copyright notice for easier
|
187
|
+
identification within third-party archives.
|
188
|
+
|
189
|
+
Copyright 2012 Penn State University
|
190
|
+
Copyright 2013 University of Notre Dame, Northwestern University, and Data Curation Experts
|
191
|
+
Copyright 2014 Data Curation Experts
|
192
|
+
Additional copyright may be held by others, as reflected in the commit log
|
193
|
+
|
194
|
+
|
195
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
196
|
+
you may not use this file except in compliance with the License.
|
197
|
+
You may obtain a copy of the License at
|
198
|
+
|
199
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
200
|
+
|
201
|
+
Unless required by applicable law or agreed to in writing, software
|
202
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
203
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
204
|
+
See the License for the specific language governing permissions and
|
205
|
+
limitations under the License.
|
data/Rakefile
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
#!/usr/bin/env rake
|
2
|
+
begin
|
3
|
+
require 'bundler/setup'
|
4
|
+
rescue LoadError
|
5
|
+
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
|
6
|
+
end
|
7
|
+
|
8
|
+
APP_RAKEFILE = File.expand_path("../spec/dummy/Rakefile", __FILE__)
|
9
|
+
load 'rails/tasks/engine.rake'
|
10
|
+
load 'rails/tasks/statistics.rake'
|
11
|
+
|
12
|
+
Bundler::GemHelper.install_tasks
|
13
|
+
|
14
|
+
Dir[File.join(File.dirname(__FILE__), 'tasks/**/*.rake')].each {|f| load f }
|
15
|
+
|
16
|
+
require 'rspec/core'
|
17
|
+
require 'rspec/core/rake_task'
|
18
|
+
|
19
|
+
desc "Run all specs in spec directory (excluding plugin specs)"
|
20
|
+
RSpec::Core::RakeTask.new(:spec => 'app:db:test:prepare')
|
21
|
+
|
22
|
+
task :default => :spec
|
23
|
+
|
24
|
+
require 'rdoc/task'
|
25
|
+
|
26
|
+
RDoc::Task.new(:rdoc) do |rdoc|
|
27
|
+
rdoc.rdoc_dir = 'rdoc'
|
28
|
+
rdoc.title = 'Samvera::Persona'
|
29
|
+
rdoc.options << '--line-numbers'
|
30
|
+
rdoc.rdoc_files.include('README.rdoc')
|
31
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
32
|
+
end
|
33
|
+
|
File without changes
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module Samvera
|
2
|
+
module Persona
|
3
|
+
module AvalonAuth
|
4
|
+
extend ActiveSupport::Concern
|
5
|
+
included do
|
6
|
+
before_action :auth
|
7
|
+
end
|
8
|
+
|
9
|
+
def auth
|
10
|
+
if current_user.nil?
|
11
|
+
flash[:notice] = "You need to login to manage users"
|
12
|
+
redirect_to main_app.new_user_session_path
|
13
|
+
elsif cannot? :manage, User
|
14
|
+
flash[:notice] = "You do not have permission to manage users"
|
15
|
+
redirect_to main_app.root_path
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,100 @@
|
|
1
|
+
module Samvera
|
2
|
+
class Persona::UsersController < ApplicationController
|
3
|
+
# include Hyrax based theme and admin only connection
|
4
|
+
begin
|
5
|
+
if defined?(Avalon)
|
6
|
+
include Samvera::Persona::AvalonAuth
|
7
|
+
end
|
8
|
+
include Hyrax::Admin::UsersControllerBehavior
|
9
|
+
rescue NameError
|
10
|
+
before_action :authenticate_user!
|
11
|
+
end
|
12
|
+
|
13
|
+
before_action :load_user, only: [:edit, :update, :destroy]
|
14
|
+
before_action :app_view_path
|
15
|
+
# NOTE: User creation/invitations handled by devise_invitable
|
16
|
+
def index
|
17
|
+
# Hyrax derivitives have breadcrumbs, Avalon does not
|
18
|
+
if defined?(add_breadcrumb)
|
19
|
+
add_breadcrumb t(:'hyrax.controls.home'), main_app.root_path
|
20
|
+
add_breadcrumb t(:'hyrax.dashboard.breadcrumbs.admin'), hyrax.dashboard_path
|
21
|
+
add_breadcrumb t(:'samvera.persona.users.index.title'), main_app.persona_users_path
|
22
|
+
end
|
23
|
+
|
24
|
+
@presenter = Samvera::Persona::UsersPresenter.new
|
25
|
+
end
|
26
|
+
|
27
|
+
# GET /persona/users/1/edit
|
28
|
+
def edit
|
29
|
+
# Hyrax derivitives have breadcrumbs, Avalon does not
|
30
|
+
if defined?(add_breadcrumb)
|
31
|
+
add_breadcrumb t(:'hyrax.controls.home'), main_app.root_path
|
32
|
+
add_breadcrumb t(:'hyrax.admin.sidebar.users'), main_app.persona_users_path
|
33
|
+
add_breadcrumb @user.display_name, main_app.edit_persona_user_path(@user)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
# PATCH/PUT persona/users/1
|
38
|
+
# PATCH/PUT persona/users/1.json
|
39
|
+
def update
|
40
|
+
# required for settings form to submit when password is left blank
|
41
|
+
if params[:user][:password].blank?
|
42
|
+
params[:user].delete(:password)
|
43
|
+
params[:user].delete(:password_confirmation)
|
44
|
+
end
|
45
|
+
|
46
|
+
respond_to do |format|
|
47
|
+
if @user.update_attributes(user_params)
|
48
|
+
@user.save
|
49
|
+
|
50
|
+
format.html { redirect_to main_app.persona_users_path, notice: 'User was successfully updated.' }#move to locales
|
51
|
+
format.json { render :show, status: :ok }
|
52
|
+
else
|
53
|
+
format.html { render :edit }
|
54
|
+
format.json { render json: @user.errors, status: :unprocessable_entity }
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
# Become a user
|
60
|
+
def impersonate
|
61
|
+
user = User.find(params[:id])
|
62
|
+
impersonate_user(user)
|
63
|
+
redirect_to main_app.root_path
|
64
|
+
end
|
65
|
+
|
66
|
+
def stop_impersonating
|
67
|
+
stop_impersonating_user
|
68
|
+
redirect_to main_app.persona_users_path, notice: t('.become.over')
|
69
|
+
end
|
70
|
+
|
71
|
+
# Delete a user from the site
|
72
|
+
def destroy
|
73
|
+
#TODO update hyku user.destroy to do roles.destroy_all instead
|
74
|
+
if @user.present? && @user.destroy
|
75
|
+
redirect_to main_app.persona_users_path, notice: t('.success', user: @user)
|
76
|
+
else
|
77
|
+
redirect_to main_app.persona_users_path flash: { error: t('.failure', user: @user) }
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
private
|
82
|
+
|
83
|
+
def load_user
|
84
|
+
if User.respond_to?(:from_url_component)
|
85
|
+
@user = User.from_url_component(params[:id])
|
86
|
+
else
|
87
|
+
@user = User.find(params[:id])
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
def app_view_path
|
92
|
+
my_engine_root = Samvera::Persona::Engine.root.to_s
|
93
|
+
prepend_view_path "#{my_engine_root}/app/views/#{Rails.application.class.parent_name.downcase}"
|
94
|
+
end
|
95
|
+
|
96
|
+
def user_params
|
97
|
+
params.require(:user).permit(:email, :username, :password, :password_confirmation, :is_superadmin, :facebook_handle, :twitter_handle, :googleplus_handle, :display_name, :address, :department, :title, :office, :chat_id, :website, :affiliation, :telephone, :avatar, :group_list, :linkedin_handle, :orcid, :arkivo_token, :arkivo_subscription, :zotero_token, :zotero_userid, :preferred_locale, role_ids: [])
|
98
|
+
end
|
99
|
+
end
|
100
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module Samvera
|
2
|
+
module Persona
|
3
|
+
module UsernameBehavior
|
4
|
+
extend ActiveSupport::Concern
|
5
|
+
included do
|
6
|
+
before_create :check_for_mandatory
|
7
|
+
end
|
8
|
+
|
9
|
+
def check_for_mandatory
|
10
|
+
if self.respond_to?(:username)
|
11
|
+
if self.email.present? && self.username.blank?
|
12
|
+
self.username = self.email
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
if self.respond_to?(:uid)
|
17
|
+
if self.email.present? && self.uid.blank?
|
18
|
+
self.uid = self.email
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
true
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
module Samvera
|
2
|
+
module Persona
|
3
|
+
class UsersPresenter
|
4
|
+
# @return [Array] an array of Users
|
5
|
+
def users
|
6
|
+
@users ||= search
|
7
|
+
end
|
8
|
+
|
9
|
+
# @return [Number] quantity of users excluding the system users and guest_users
|
10
|
+
def user_count
|
11
|
+
users.count
|
12
|
+
end
|
13
|
+
|
14
|
+
# @return [Array] an array of user roles
|
15
|
+
def user_roles(user)
|
16
|
+
user.groups
|
17
|
+
end
|
18
|
+
|
19
|
+
def last_accessed(user)
|
20
|
+
user.respond_to?(:last_sign_in_at) && user.last_sign_in_at ? user.last_sign_in_at : user.created_at
|
21
|
+
end
|
22
|
+
|
23
|
+
# return [Boolean] true if the devise trackable module is enabled.
|
24
|
+
def show_last_access?
|
25
|
+
return @show_last_access unless @show_last_access.nil?
|
26
|
+
@show_last_access = ::User.devise_modules.include?(:trackable)
|
27
|
+
end
|
28
|
+
|
29
|
+
private
|
30
|
+
|
31
|
+
# Returns a list of users excluding the system users and guest_users
|
32
|
+
def search
|
33
|
+
if ::User.respond_to?(:registered)
|
34
|
+
::User.registered.without_system_accounts
|
35
|
+
else
|
36
|
+
::User.all
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,63 @@
|
|
1
|
+
<%#
|
2
|
+
Copyright 2011-2018, The Trustees of Indiana University and Northwestern
|
3
|
+
University. Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
you may not use this file except in compliance with the License.
|
5
|
+
|
6
|
+
You may obtain a copy of the License at
|
7
|
+
|
8
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
9
|
+
|
10
|
+
Unless required by applicable law or agreed to in writing, software distributed
|
11
|
+
under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
|
12
|
+
CONDITIONS OF ANY KIND, either express or implied. See the License for the
|
13
|
+
specific language governing permissions and limitations under the License.
|
14
|
+
--- END LICENSE_HEADER BLOCK ---
|
15
|
+
%>
|
16
|
+
<%= form_for(@user, url: main_app.persona_user_path(@user), method: "put", html: { class: 'form' } ) do |f| %>
|
17
|
+
|
18
|
+
<div class="panel-body">
|
19
|
+
<% if @user.errors.any? %>
|
20
|
+
<div id="error_explanation" class="alert alert-danger">
|
21
|
+
<p><%= pluralize(@user.errors.count, "error") %> prohibited this user from being saved:</p>
|
22
|
+
<ul>
|
23
|
+
<% @user.errors.messages.each do |key, messages| %>
|
24
|
+
<li><%= key %> "<%= @user.errors&.details[key]&.first&.[](:value) %>" <%= messages.join(' and ') %></li>
|
25
|
+
<% end %>
|
26
|
+
</ul>
|
27
|
+
</div>
|
28
|
+
<% end %>
|
29
|
+
|
30
|
+
<div class="form-group">
|
31
|
+
<%= f.label :email %><br />
|
32
|
+
<%= f.email_field :email, autofocus: true, autocomplete: "email", class: 'form-control' %>
|
33
|
+
</div>
|
34
|
+
|
35
|
+
<% if f.object.respond_to?(:username) %>
|
36
|
+
<div class="form-group">
|
37
|
+
<%= f.label :username %><br />
|
38
|
+
<%= f.text_field :username, class: 'form-control' %>
|
39
|
+
</div>
|
40
|
+
<% end %>
|
41
|
+
|
42
|
+
<div class="form-group">
|
43
|
+
<%= f.label :password %> <i>(leave blank if you don't want to change it)</i><br />
|
44
|
+
<%= f.password_field :password, autocomplete: "off", class: 'form-control' %>
|
45
|
+
<% if @minimum_password_length %>
|
46
|
+
<br />
|
47
|
+
<em><%= @minimum_password_length %> characters minimum</em>
|
48
|
+
<% end %>
|
49
|
+
</div>
|
50
|
+
|
51
|
+
<div class="form-group">
|
52
|
+
<%= f.label :password_confirmation %><br />
|
53
|
+
<%= f.password_field :password_confirmation, autocomplete: "off", class: 'form-control' %>
|
54
|
+
</div>
|
55
|
+
|
56
|
+
<div class="actions">
|
57
|
+
<%= f.submit "Update", class: 'btn btn-primary' %>
|
58
|
+
<%= link_to 'Cancel', main_app.persona_users_path, class: 'btn btn-default action-cancel' %>
|
59
|
+
</div>
|
60
|
+
</div>
|
61
|
+
<% end %>
|
62
|
+
|
63
|
+
|
@@ -0,0 +1 @@
|
|
1
|
+
<h2><span class="fa fa-user"></span> <%= t('.title') %></h2>
|
@@ -0,0 +1,25 @@
|
|
1
|
+
<div class="form-inputs">
|
2
|
+
<%= f.input :display_name, label: 'Display Name' %>
|
3
|
+
<%= f.input :email, hint: '' %>
|
4
|
+
<%= f.input :is_superadmin, as: :boolean %>
|
5
|
+
<%= f.input :password, hint: 'Only if creating or changing' %>
|
6
|
+
<%= f.input :facebook_handle %>
|
7
|
+
<%= f.input :twitter_handle %>
|
8
|
+
<%= f.input :googleplus_handle %>
|
9
|
+
<%= f.input :address %>
|
10
|
+
<%= f.input :department %>
|
11
|
+
<%= f.input :title, hint: '' %>
|
12
|
+
<%= f.input :office %>
|
13
|
+
<%= f.input :chat_id %>
|
14
|
+
<%= f.input :website %>
|
15
|
+
<%= f.input :affiliation %>
|
16
|
+
<%= f.input :telephone %>
|
17
|
+
<%= f.input :avatar %>
|
18
|
+
<%= f.input :group_list %>
|
19
|
+
<%= f.input :linkedin_handle %>
|
20
|
+
<%= f.input :orcid %>
|
21
|
+
<%= f.input :arkivo_token %>
|
22
|
+
<%= f.input :arkivo_subscription %>
|
23
|
+
<%= f.input :preferred_locale %>
|
24
|
+
</div>
|
25
|
+
|
@@ -0,0 +1,29 @@
|
|
1
|
+
<% content_for :page_header do %>
|
2
|
+
<h1><span class="fa fa-gears"></span> <%= t(".header") %></h1>
|
3
|
+
<% end %>
|
4
|
+
|
5
|
+
<div class="row">
|
6
|
+
<div class="col-md-12">
|
7
|
+
<div class="panel panel-default user-form">
|
8
|
+
<%= simple_form_for @user, url: main_app.persona_user_path(@user), html: { class: 'form' } do |f| %>
|
9
|
+
<div class="panel-body">
|
10
|
+
<% if @user.errors.any? %>
|
11
|
+
<div id="error_explanation" class="alert alert-danger">
|
12
|
+
<h2><%= pluralize(@user.errors.count, "error") %> prohibited this user from being saved:</h2>
|
13
|
+
<ul>
|
14
|
+
<% @user.errors.messages.each do |key, messages| %>
|
15
|
+
<li><%= key %> "<%= @user.errors&.details[key]&.first&.[](:value) %>" <%= messages.join(' and ') %></li>
|
16
|
+
<% end %>
|
17
|
+
</ul>
|
18
|
+
</div>
|
19
|
+
<% end %>
|
20
|
+
|
21
|
+
<%= render 'form', user: @user, f: f %>
|
22
|
+
|
23
|
+
<%= f.submit class: 'btn btn-primary' %>
|
24
|
+
<%= link_to t('edit_form.cancel'), main_app.persona_users_path, class: 'btn btn-link action-cancel' %>
|
25
|
+
</div>
|
26
|
+
<% end %>
|
27
|
+
</div>
|
28
|
+
</div>
|
29
|
+
</div>
|