ucb_rails_user 5.0.0 → 6.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +33 -9
- data/app/controllers/{ucb_rails_user/concerns/controller_methods.rb → concerns/ucb_rails_user/auth_concerns.rb} +1 -1
- data/app/controllers/{ucb_rails_user/concerns/home_controller.rb → concerns/ucb_rails_user/home_controller_concerns.rb} +1 -2
- data/app/controllers/{ucb_rails_user/concerns/impersonations_controller.rb → concerns/ucb_rails_user/impersonations_controller_concerns.rb} +2 -3
- data/app/controllers/{ucb_rails_user/concerns/sessions_controller.rb → concerns/ucb_rails_user/sessions_controller_concerns.rb} +2 -2
- data/app/controllers/{ucb_rails_user/concerns/users_controller.rb → concerns/ucb_rails_user/users_controller_concerns.rb} +7 -8
- data/app/controllers/ucb_rails_user/home_controller.rb +3 -4
- data/app/controllers/ucb_rails_user/impersonations_controller.rb +2 -2
- data/app/controllers/ucb_rails_user/sessions_controller.rb +2 -2
- data/app/controllers/ucb_rails_user/users_controller.rb +2 -2
- data/app/models/{ucb_rails_user/concerns → concerns/ucb_rails_user}/impersonation_concerns.rb +1 -1
- data/app/models/{ucb_rails_user/concerns → concerns/ucb_rails_user}/user_concerns.rb +2 -3
- data/app/models/{ucb_rails_user/concerns → concerns/ucb_rails_user}/user_roles_concerns.rb +1 -1
- data/app/models/ucb_rails_user/configuration/configuration.rb +1 -1
- data/app/models/ucb_rails_user/impersonation.rb +1 -1
- data/app/models/ucb_rails_user/user_ldap_service.rb +4 -4
- data/app/models/ucb_rails_user/user_search.rb +3 -3
- data/app/models/ucb_rails_user/user_session_manager/base.rb +2 -2
- data/app/models/ucb_rails_user/user_uc_path_service.rb +2 -3
- data/app/views/ucb_rails_user/users/_user.html.haml +1 -2
- data/lib/tasks/ucb_rails_user_tasks.rake +8 -4
- data/lib/ucb_rails_user/version.rb +1 -1
- data/lib/ucb_rails_user.rb +6 -1
- metadata +15 -16
- data/app/models/ucb_rails_user/user.rb +0 -8
- /data/{db/migrate/20170324221936_create_users.rb → lib/templates/db/create_users.rb} +0 -0
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: fd76a5b19aa06b93d571891fc4151dfbcf513801ccd575a45a3765734b9ba5f5
|
|
4
|
+
data.tar.gz: de7650bed13196b8531dc092203e4dcb6149d94b5367024104ae235439f909bf
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 648c9f48aaf4098ad18537a292340ad97579bfe39573b83a11dc72351c4d90f1ea6503112329e8f218ea3efd62c0640cf400eefbe57bf5dba683fa808c819163
|
|
7
|
+
data.tar.gz: 526aad45c5d1a944245c8b0a0767c27f77a08da8f677e69b010c3bc8fce2e15b2f2f73c27aad3ec81e278718da0b39a081c9fdb673ed13f00b9e0975015a030b
|
data/README.md
CHANGED
|
@@ -2,13 +2,13 @@
|
|
|
2
2
|
|
|
3
3
|
A [Rails engine](http://guides.rubyonrails.org/engines.html) that provides authentication and user management for UCB Rails apps. By adding this engine to your app, you get:
|
|
4
4
|
|
|
5
|
-
* a full [User model](https://github.com/ucb-ist-eas/ucb_rails_user/blob/master/app/models/user.rb) which can be customized by host apps
|
|
6
5
|
* login and logout via [CAS](https://calnetweb.berkeley.edu/calnet-technologists/cas)
|
|
7
6
|
* automatic creation of user records following CAS authentication
|
|
8
7
|
* controller filters that block access to resources unless user is logged in
|
|
9
8
|
* a default home page that reflects user's login status
|
|
10
9
|
* admin screens for updating and deleting user records
|
|
11
10
|
* ability for admins to impersonate other users
|
|
11
|
+
* optional generator to create a users table that's compatible with this gem
|
|
12
12
|
|
|
13
13
|
This engine also includes the [Datatables](https://datatables.net/) JQuery plug-in, which is used in the user management screens, and [typeahead.js](https://github.com/twitter/typeahead.js) for autocomplete. Host apps can make use of these libraries as well.
|
|
14
14
|
|
|
@@ -16,14 +16,18 @@ This engine also includes the [Datatables](https://datatables.net/) JQuery plug-
|
|
|
16
16
|
|
|
17
17
|
Version 2.0 and greater of this gem sets a user's `employee_id` to the new UCPath employee id, rather than the legacy HCM employee id. If you need to use the older ID, use version 1.1.3 of this gem, or lower.
|
|
18
18
|
|
|
19
|
+
## Upgrading to version 6.0+
|
|
20
|
+
|
|
21
|
+
See [this wiki page](https://github.com/ucb-ist-eas/ucb_rails_user/wiki/Upgrading-to-version-6.0) for details.
|
|
22
|
+
|
|
19
23
|
## Upgrading to version 3.0+ from version 2.x
|
|
20
24
|
|
|
21
25
|
See [this wiki page](https://github.com/ucb-ist-eas/ucb_rails_user/wiki/Upgrading-to-version-3.0) for details.
|
|
22
26
|
|
|
23
27
|
## Prerequisites
|
|
24
28
|
|
|
25
|
-
* Ruby >=
|
|
26
|
-
* Rails >=
|
|
29
|
+
* Ruby >= 3.0
|
|
30
|
+
* Rails >= 6.0
|
|
27
31
|
|
|
28
32
|
Older versions may work as well, but they haven't been tested.
|
|
29
33
|
|
|
@@ -51,7 +55,7 @@ bundle install
|
|
|
51
55
|
3. Add this line to your host app's `ApplicationController:`
|
|
52
56
|
|
|
53
57
|
```ruby
|
|
54
|
-
include UcbRailsUser::
|
|
58
|
+
include UcbRailsUser::AuthConcerns
|
|
55
59
|
```
|
|
56
60
|
|
|
57
61
|
4. Copy [this initializer file](https://github.com/ucb-ist-eas/ucb_rails_cli/blob/master/lib/ucb_rails_cli/templates/config/initializers/ucb_rails_user.rb) into your host app's `config/initializer` directory.
|
|
@@ -62,13 +66,15 @@ include UcbRailsUser::Concerns::ControllerMethods
|
|
|
62
66
|
root to: UcbRailsUser::HomeController.action(:index)
|
|
63
67
|
```
|
|
64
68
|
|
|
65
|
-
6. Copy the migrations for the `
|
|
69
|
+
6. Copy the migrations for the `Impersonation` models from the engine into your host app, and run them:
|
|
66
70
|
|
|
67
71
|
```
|
|
68
72
|
bin/rails railties:install:migrations
|
|
69
73
|
bin/rake db:migrate
|
|
70
74
|
```
|
|
71
75
|
|
|
76
|
+
7. (optional) If you don't already have a `users` table, you can generate one with a Rails task (see next section below)
|
|
77
|
+
|
|
72
78
|
8. Update your assets files
|
|
73
79
|
|
|
74
80
|
In `application.css` add this line:
|
|
@@ -83,7 +89,7 @@ And in `application.js` add this line:
|
|
|
83
89
|
//= require ucb_rails_user/scripts
|
|
84
90
|
```
|
|
85
91
|
|
|
86
|
-
|
|
92
|
+
9. Restart your host app as usual
|
|
87
93
|
|
|
88
94
|
You should be able to access the following routes:
|
|
89
95
|
|
|
@@ -95,6 +101,24 @@ You should be able to access the following routes:
|
|
|
95
101
|
* `/admin/stop_impersonation`: this stops an active impersonation
|
|
96
102
|
* `/admin/users/toggle_superuser`: in dev mode, you can use this url to turn the superuser flag of your account on and off
|
|
97
103
|
|
|
104
|
+
## User model
|
|
105
|
+
|
|
106
|
+
This gem does not define a model representing a user - that is left to the host app. However, if you don't have such a model yet, you can generate a migration for one by running:
|
|
107
|
+
|
|
108
|
+
```bash
|
|
109
|
+
bin/rails ucb_rails_user:create_users_table
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
This will create a migration for a `users` table containing the fields this gem expects to see.
|
|
113
|
+
|
|
114
|
+
### Alternate naming
|
|
115
|
+
|
|
116
|
+
By default, this gem expects the user model to be named `User`, but if you're using a different class name, you can specify that name in an initializer (e.g. `config/initializers/ucb_rails_user.rb`):
|
|
117
|
+
|
|
118
|
+
```ruby
|
|
119
|
+
UcbRailsUser.user_class = "Entity"
|
|
120
|
+
```
|
|
121
|
+
|
|
98
122
|
## Routing
|
|
99
123
|
|
|
100
124
|
The [config/routes.rb file](https://github.com/ucb-ist-eas/ucb_rails_user/blob/master/config/routes.rb) will show you the routes that this engine provides out of the box. But if necessary, you can override these routes in your host app.
|
|
@@ -149,9 +173,9 @@ Alice stops impersonating Bob:
|
|
|
149
173
|
* `logged_in_user` returns Alice
|
|
150
174
|
* `current_user` returns Alice
|
|
151
175
|
|
|
152
|
-
##
|
|
176
|
+
## Auth Helpers
|
|
153
177
|
|
|
154
|
-
If you followed the setup instructions above, your `ApplicationController` should be including `UcbRails::
|
|
178
|
+
If you followed the setup instructions above, your `ApplicationController` should be including `UcbRails::AuthConcerns.` This provides a number of utility methods you can use in your controllers:
|
|
155
179
|
|
|
156
180
|
* `current_user`: returns the `User` instance for the currently logged-in user, or `nil` if user is not logged in. If the logged-in user is impersonating another user, this will return the impersonated user
|
|
157
181
|
* `logged_in_user`: this returns the user who logged in with their Calnet credentials, even if that user is impersonating another user
|
|
@@ -232,7 +256,7 @@ Similarly, to override `UserController,` add `app/controllers/ucb_rails/user_con
|
|
|
232
256
|
|
|
233
257
|
```ruby
|
|
234
258
|
class UcbRailsUser::UsersController < ApplicationController
|
|
235
|
-
include UcbRailsUser::
|
|
259
|
+
include UcbRailsUser::UsersControllerConcerns
|
|
236
260
|
|
|
237
261
|
# add your code here
|
|
238
262
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
module UcbRailsUser::
|
|
1
|
+
module UcbRailsUser::ImpersonationsControllerConcerns
|
|
2
2
|
extend ActiveSupport::Concern
|
|
3
3
|
|
|
4
4
|
included do
|
|
@@ -10,7 +10,7 @@ module UcbRailsUser::Concerns::ImpersonationsController
|
|
|
10
10
|
end
|
|
11
11
|
|
|
12
12
|
def create
|
|
13
|
-
target = UcbRailsUser
|
|
13
|
+
target = UcbRailsUser.user_class.find_by(id: params[:ucb_rails_user_impersonation][:target_id])
|
|
14
14
|
if logged_in_user.impersonate!(target)
|
|
15
15
|
flash[:info] = "You are now impersonating #{target.full_name}"
|
|
16
16
|
return redirect_to "/"
|
|
@@ -40,4 +40,3 @@ module UcbRailsUser::Concerns::ImpersonationsController
|
|
|
40
40
|
end
|
|
41
41
|
|
|
42
42
|
end
|
|
43
|
-
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
module UcbRailsUser::
|
|
1
|
+
module UcbRailsUser::SessionsControllerConcerns
|
|
2
2
|
extend ActiveSupport::Concern
|
|
3
3
|
|
|
4
4
|
included do
|
|
@@ -35,7 +35,7 @@ module UcbRailsUser::Concerns::SessionsController
|
|
|
35
35
|
user_session_manager.logout(current_user)
|
|
36
36
|
provider = session[:omniauth_provider]
|
|
37
37
|
reset_session
|
|
38
|
-
redirect_to redirect_url(provider)
|
|
38
|
+
redirect_to redirect_url(provider), allow_other_host: true
|
|
39
39
|
end
|
|
40
40
|
|
|
41
41
|
# Action called when unauthorized access attempted
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
module UcbRailsUser::
|
|
1
|
+
module UcbRailsUser::UsersControllerConcerns
|
|
2
2
|
extend ActiveSupport::Concern
|
|
3
3
|
|
|
4
4
|
included do
|
|
@@ -8,9 +8,9 @@ module UcbRailsUser::Concerns::UsersController
|
|
|
8
8
|
end
|
|
9
9
|
|
|
10
10
|
def index
|
|
11
|
-
@users = UcbRailsUser
|
|
11
|
+
@users = UcbRailsUser.user_class.all
|
|
12
12
|
respond_to do |format|
|
|
13
|
-
format.html { @users = UcbRailsUser
|
|
13
|
+
format.html { @users = UcbRailsUser.user_class.all }
|
|
14
14
|
format.json { render json: UcbRails::UsersDatatable.new(view_context).as_json }
|
|
15
15
|
end
|
|
16
16
|
end
|
|
@@ -40,7 +40,7 @@ module UcbRailsUser::Concerns::UsersController
|
|
|
40
40
|
def create
|
|
41
41
|
uid = params.fetch(:ldap_uid)
|
|
42
42
|
user = nil
|
|
43
|
-
if user = UcbRailsUser
|
|
43
|
+
if user = UcbRailsUser.user_class.find_by_ldap_uid(uid)
|
|
44
44
|
flash[:warning] = "User already exists"
|
|
45
45
|
else
|
|
46
46
|
begin
|
|
@@ -91,7 +91,7 @@ module UcbRailsUser::Concerns::UsersController
|
|
|
91
91
|
:sort => :last_first_downcase
|
|
92
92
|
)
|
|
93
93
|
uid_strings = @lps_entries.map { |entry| entry.uid&.to_s }.compact
|
|
94
|
-
@lps_existing_uids = UcbRailsUser
|
|
94
|
+
@lps_existing_uids = UcbRailsUser.user_class.where(ldap_uid: uid_strings).pluck(:uid)
|
|
95
95
|
render 'ucb_rails_user/lps/search'
|
|
96
96
|
end
|
|
97
97
|
|
|
@@ -115,7 +115,7 @@ module UcbRailsUser::Concerns::UsersController
|
|
|
115
115
|
private
|
|
116
116
|
|
|
117
117
|
def user_params(extra_params = [])
|
|
118
|
-
params.require(:
|
|
118
|
+
params.require(:user).permit([
|
|
119
119
|
:superuser_flag,
|
|
120
120
|
:inactive_flag,
|
|
121
121
|
:first_name,
|
|
@@ -131,8 +131,7 @@ module UcbRailsUser::Concerns::UsersController
|
|
|
131
131
|
end
|
|
132
132
|
|
|
133
133
|
def find_user
|
|
134
|
-
@user ||= UcbRailsUser
|
|
134
|
+
@user ||= UcbRailsUser.user_class.find(params.fetch(:id))
|
|
135
135
|
end
|
|
136
136
|
|
|
137
137
|
end
|
|
138
|
-
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
class UcbRailsUser::HomeController < ApplicationController
|
|
2
|
-
include UcbRailsUser::
|
|
3
|
-
include UcbRailsUser::
|
|
2
|
+
include UcbRailsUser::AuthConcerns
|
|
3
|
+
include UcbRailsUser::HomeControllerConcerns
|
|
4
4
|
|
|
5
5
|
# Don't add anything more here - any logic for this class should go into
|
|
6
|
-
#
|
|
6
|
+
# UcbRailsUser::HomeControllerConcerns. This will make it much easier for host
|
|
7
7
|
# apps to customize behavior if they need to
|
|
8
8
|
# http://guides.rubyonrails.org/engines.html#implementing-decorator-pattern-using-activesupport-concern
|
|
9
9
|
end
|
|
10
|
-
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
class UcbRailsUser::ImpersonationsController < ApplicationController
|
|
2
|
-
include UcbRailsUser::
|
|
2
|
+
include UcbRailsUser::ImpersonationsControllerConcerns
|
|
3
3
|
|
|
4
4
|
# Don't add anything more here - any logic for this controller should go into
|
|
5
|
-
#
|
|
5
|
+
# UcbRiailsUser::ImpersonationsControllerConcerns. This will make it much easier for host apps to customize
|
|
6
6
|
# behavior if they need to
|
|
7
7
|
# http://guides.rubyonrails.org/engines.html#implementing-decorator-pattern-using-activesupport-concern
|
|
8
8
|
end
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
# Manages starting and ending of sessions, i.e., logging in and out.
|
|
2
2
|
class UcbRailsUser::SessionsController < ApplicationController
|
|
3
|
-
include UcbRailsUser::
|
|
3
|
+
include UcbRailsUser::SessionsControllerConcerns
|
|
4
4
|
|
|
5
5
|
# Don't add anything more here - any logic for this class should go into
|
|
6
|
-
#
|
|
6
|
+
# UcbRailsUser::SessionsControllerConcerns. This will make it much easier for host
|
|
7
7
|
# apps to customize behavior if they need to
|
|
8
8
|
# http://guides.rubyonrails.org/engines.html#implementing-decorator-pattern-using-activesupport-concern
|
|
9
9
|
end
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
class UcbRailsUser::UsersController < ApplicationController
|
|
2
|
-
include UcbRailsUser::
|
|
2
|
+
include UcbRailsUser::UsersControllerConcerns
|
|
3
3
|
|
|
4
4
|
# Don't add anything more here - any logic for this controller should go into
|
|
5
|
-
#
|
|
5
|
+
# UcbRailsUser::UserControllerConcerns. This will make it much easier for host apps to customize
|
|
6
6
|
# behavior if they need to
|
|
7
7
|
# http://guides.rubyonrails.org/engines.html#implementing-decorator-pattern-using-activesupport-concern
|
|
8
8
|
end
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
module UcbRailsUser::
|
|
1
|
+
module UcbRailsUser::UserConcerns
|
|
2
2
|
extend ActiveSupport::Concern
|
|
3
3
|
|
|
4
4
|
included do
|
|
@@ -46,7 +46,7 @@ module UcbRailsUser::Concerns::UserConcerns
|
|
|
46
46
|
if target.respond_to?(:id)
|
|
47
47
|
target.id
|
|
48
48
|
else
|
|
49
|
-
UcbRailsUser
|
|
49
|
+
UcbRailsUser.user_class.find_by(id: target)&.id
|
|
50
50
|
end
|
|
51
51
|
return false unless impersonation_is_valid?(target_id)
|
|
52
52
|
@current_impersonation = create_impersonation(target_id)
|
|
@@ -114,4 +114,3 @@ module UcbRailsUser::Concerns::UserConcerns
|
|
|
114
114
|
end
|
|
115
115
|
|
|
116
116
|
end
|
|
117
|
-
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
class UcbRailsUser::Impersonation < ApplicationRecord
|
|
2
|
-
include UcbRailsUser::
|
|
2
|
+
include UcbRailsUser::ImpersonationConcerns
|
|
3
3
|
|
|
4
4
|
# Don't add anything more here - any logic for the Impersonation class should go into
|
|
5
5
|
# ImpersonationConcerns. This will make it much easier for host apps to customize
|
|
@@ -12,7 +12,7 @@ class UcbRailsUser::UserLdapService
|
|
|
12
12
|
def create_user_from_ldap_entry(ldap_entry)
|
|
13
13
|
UcbRailsUser.logger.debug "create_user_from_ldap_entry #{ldap_entry.uid}"
|
|
14
14
|
|
|
15
|
-
UcbRailsUser
|
|
15
|
+
UcbRailsUser.user_class.create! do |u|
|
|
16
16
|
u.ldap_uid = ldap_entry.uid
|
|
17
17
|
u.employee_id = ldap_entry.employee_id
|
|
18
18
|
u.affiliate_id = ldap_entry.affiliate_id
|
|
@@ -34,7 +34,7 @@ class UcbRailsUser::UserLdapService
|
|
|
34
34
|
def update_user_from_ldap_entry(ldap_entry)
|
|
35
35
|
UcbRailsUser.logger.debug "update_user_from_ldap_entry #{ldap_entry.uid}"
|
|
36
36
|
|
|
37
|
-
UcbRailsUser
|
|
37
|
+
UcbRailsUser.user_class.find_by_ldap_uid!(ldap_entry.uid).tap do |user|
|
|
38
38
|
user.employee_id = ldap_entry.employee_id if user.respond_to?(:employee_id=)
|
|
39
39
|
user.affiliate_id = ldap_entry.affiliate_id
|
|
40
40
|
user.student_id = ldap_entry.student_id
|
|
@@ -47,7 +47,7 @@ class UcbRailsUser::UserLdapService
|
|
|
47
47
|
end
|
|
48
48
|
|
|
49
49
|
def create_or_update_user(uid)
|
|
50
|
-
if user = UcbRailsUser
|
|
50
|
+
if user = UcbRailsUser.user_class.find_by_ldap_uid(uid)
|
|
51
51
|
update_user_from_uid(uid)
|
|
52
52
|
else
|
|
53
53
|
create_user_from_uid(uid)
|
|
@@ -58,7 +58,7 @@ class UcbRailsUser::UserLdapService
|
|
|
58
58
|
# LDAP returns some values as Net::BER::BerIdentifiedString instances, and not
|
|
59
59
|
# all DBs seem to handle that well (e.g. Oracle) - we might want to fix LDAP library
|
|
60
60
|
# to smooth this over?
|
|
61
|
-
if user = UcbRailsUser
|
|
61
|
+
if user = UcbRailsUser.user_class.find_by_ldap_uid(entry.uid.to_s)
|
|
62
62
|
update_user_from_ldap_entry(entry)
|
|
63
63
|
else
|
|
64
64
|
create_user_from_ldap_entry(entry)
|
|
@@ -10,10 +10,10 @@ module UcbRailsUser::UserSearch
|
|
|
10
10
|
.map { |n| "#{n}%" }
|
|
11
11
|
query =
|
|
12
12
|
if name1.present? && name2.present?
|
|
13
|
-
UcbRailsUser
|
|
14
|
-
.or(UcbRailsUser
|
|
13
|
+
UcbRailsUser.user_class.where("LOWER(first_name) LIKE ? AND LOWER(last_name) LIKE ?", name1, name2)
|
|
14
|
+
.or(UcbRailsUser.user_class.where("LOWER(last_name) LIKE ? AND LOWER(first_name) LIKE ?", name1, name2))
|
|
15
15
|
else
|
|
16
|
-
UcbRailsUser
|
|
16
|
+
UcbRailsUser.user_class.where("LOWER(first_name) LIKE ? OR LOWER(last_name) LIKE ?", name1, name1)
|
|
17
17
|
end
|
|
18
18
|
query.order(:last_name, :first_name)
|
|
19
19
|
end
|
|
@@ -31,11 +31,11 @@ class UcbRailsUser::UserSessionManager::Base
|
|
|
31
31
|
private
|
|
32
32
|
|
|
33
33
|
def active_user
|
|
34
|
-
@active_user ||= UcbRailsUser
|
|
34
|
+
@active_user ||= UcbRailsUser.user_class.active.find_by_ldap_uid(uid)
|
|
35
35
|
end
|
|
36
36
|
|
|
37
37
|
def active_admin_user
|
|
38
|
-
@active_user ||= UcbRailsUser
|
|
38
|
+
@active_user ||= UcbRailsUser.user_class.active.superuser.find_by_ldap_uid(uid)
|
|
39
39
|
end
|
|
40
40
|
|
|
41
41
|
def ldap_person_user_wrapper(ldap_person_entry)
|
|
@@ -7,14 +7,14 @@ class UcbRailsUser::UserUcPathService
|
|
|
7
7
|
def create_or_update_user_from_employee_id(employee_id)
|
|
8
8
|
ucpath_entry = ucpath_client.fetch_employee_data_with_employee_id(employee_id)
|
|
9
9
|
return nil unless ucpath_entry.present?
|
|
10
|
-
user = UcbRailsUser
|
|
10
|
+
user = UcbRailsUser.user_class.find_or_initialize_by(employee_id: employee_id)
|
|
11
11
|
update_user_record_from_ucpath_entry!(user, ucpath_entry)
|
|
12
12
|
end
|
|
13
13
|
|
|
14
14
|
def create_or_update_user_from_ldap_uid(ldap_uid)
|
|
15
15
|
ucpath_entry = ucpath_client.fetch_employee_data_with_ldap_uid(ldap_uid)
|
|
16
16
|
return nil unless ucpath_entry.present?
|
|
17
|
-
user = UcbRailsUser
|
|
17
|
+
user = UcbRailsUser.user_class.find_or_initialize_by(ldap_uid: ldap_uid)
|
|
18
18
|
update_user_record_from_ucpath_entry!(user, ucpath_entry)
|
|
19
19
|
end
|
|
20
20
|
|
|
@@ -118,4 +118,3 @@ class UcbRailsUser::UserUcPathService
|
|
|
118
118
|
end
|
|
119
119
|
|
|
120
120
|
end
|
|
121
|
-
|
|
@@ -8,5 +8,4 @@
|
|
|
8
8
|
%td.min= user.ldap_uid
|
|
9
9
|
%td.min= user.employee_id
|
|
10
10
|
%td= link_to('edit', edit_admin_user_path(user), :class => 'btn btn-info btn-xs', :id => dom_id(user, 'edit'))
|
|
11
|
-
%td=
|
|
12
|
-
|
|
11
|
+
%td= button_to 'delete', admin_user_path(user), method: :delete, data: {confirm: "Are you sure?"}, class: "btn btn-danger btn-xs"
|
|
@@ -1,4 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
namespace :ucb_rails_user do
|
|
2
|
+
desc "Create a migration for a users table that is compatible with this gem"
|
|
3
|
+
task create_users_table: :environment do
|
|
4
|
+
sh "bin/rails g migration CreateUsersToo"
|
|
5
|
+
new_migration_file = Dir.glob("db/migrate/*_create_users_too.rb").last
|
|
6
|
+
sh "cat #{File.expand_path('../..', __FILE__)}/templates/db/create_users.rb > #{new_migration_file}"
|
|
7
|
+
end
|
|
8
|
+
end
|
data/lib/ucb_rails_user.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: ucb_rails_user
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version:
|
|
4
|
+
version: 6.0.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Steve Downey
|
|
@@ -11,7 +11,7 @@ authors:
|
|
|
11
11
|
autorequire:
|
|
12
12
|
bindir: bin
|
|
13
13
|
cert_chain: []
|
|
14
|
-
date: 2023-
|
|
14
|
+
date: 2023-10-06 00:00:00.000000000 Z
|
|
15
15
|
dependencies:
|
|
16
16
|
- !ruby/object:Gem::Dependency
|
|
17
17
|
name: rails
|
|
@@ -171,14 +171,14 @@ dependencies:
|
|
|
171
171
|
requirements:
|
|
172
172
|
- - "~>"
|
|
173
173
|
- !ruby/object:Gem::Version
|
|
174
|
-
version: '
|
|
174
|
+
version: '6.4'
|
|
175
175
|
type: :development
|
|
176
176
|
prerelease: false
|
|
177
177
|
version_requirements: !ruby/object:Gem::Requirement
|
|
178
178
|
requirements:
|
|
179
179
|
- - "~>"
|
|
180
180
|
- !ruby/object:Gem::Version
|
|
181
|
-
version: '
|
|
181
|
+
version: '6.4'
|
|
182
182
|
- !ruby/object:Gem::Dependency
|
|
183
183
|
name: sqlite3
|
|
184
184
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -278,7 +278,7 @@ dependencies:
|
|
|
278
278
|
- !ruby/object:Gem::Version
|
|
279
279
|
version: '0'
|
|
280
280
|
- !ruby/object:Gem::Dependency
|
|
281
|
-
name:
|
|
281
|
+
name: simplecov
|
|
282
282
|
requirement: !ruby/object:Gem::Requirement
|
|
283
283
|
requirements:
|
|
284
284
|
- - ">="
|
|
@@ -313,20 +313,20 @@ files:
|
|
|
313
313
|
- app/assets/stylesheets/ucb_rails_user/main.sass
|
|
314
314
|
- app/assets/stylesheets/ucb_rails_user/styles.css
|
|
315
315
|
- app/assets/stylesheets/ucb_rails_user/typeahead_tweaks.sass
|
|
316
|
-
- app/controllers/ucb_rails_user/
|
|
317
|
-
- app/controllers/ucb_rails_user/
|
|
318
|
-
- app/controllers/ucb_rails_user/
|
|
319
|
-
- app/controllers/ucb_rails_user/
|
|
320
|
-
- app/controllers/ucb_rails_user/
|
|
316
|
+
- app/controllers/concerns/ucb_rails_user/auth_concerns.rb
|
|
317
|
+
- app/controllers/concerns/ucb_rails_user/home_controller_concerns.rb
|
|
318
|
+
- app/controllers/concerns/ucb_rails_user/impersonations_controller_concerns.rb
|
|
319
|
+
- app/controllers/concerns/ucb_rails_user/sessions_controller_concerns.rb
|
|
320
|
+
- app/controllers/concerns/ucb_rails_user/users_controller_concerns.rb
|
|
321
321
|
- app/controllers/ucb_rails_user/home_controller.rb
|
|
322
322
|
- app/controllers/ucb_rails_user/impersonations_controller.rb
|
|
323
323
|
- app/controllers/ucb_rails_user/sessions_controller.rb
|
|
324
324
|
- app/controllers/ucb_rails_user/users_controller.rb
|
|
325
325
|
- app/helpers/ucb_rails_user/users_helper.rb
|
|
326
326
|
- app/helpers/ucb_rails_user_helper.rb
|
|
327
|
-
- app/models/ucb_rails_user/
|
|
328
|
-
- app/models/ucb_rails_user/
|
|
329
|
-
- app/models/ucb_rails_user/
|
|
327
|
+
- app/models/concerns/ucb_rails_user/impersonation_concerns.rb
|
|
328
|
+
- app/models/concerns/ucb_rails_user/user_concerns.rb
|
|
329
|
+
- app/models/concerns/ucb_rails_user/user_roles_concerns.rb
|
|
330
330
|
- app/models/ucb_rails_user/configuration/cas.rb
|
|
331
331
|
- app/models/ucb_rails_user/configuration/configuration.rb
|
|
332
332
|
- app/models/ucb_rails_user/configuration/email.rb
|
|
@@ -336,7 +336,6 @@ files:
|
|
|
336
336
|
- app/models/ucb_rails_user/ldap_person/entry.rb
|
|
337
337
|
- app/models/ucb_rails_user/ldap_person/finder.rb
|
|
338
338
|
- app/models/ucb_rails_user/ldap_person/test_finder.rb
|
|
339
|
-
- app/models/ucb_rails_user/user.rb
|
|
340
339
|
- app/models/ucb_rails_user/user_ldap_service.rb
|
|
341
340
|
- app/models/ucb_rails_user/user_search.rb
|
|
342
341
|
- app/models/ucb_rails_user/user_session_manager/active_in_user_table.rb
|
|
@@ -366,9 +365,9 @@ files:
|
|
|
366
365
|
- config/initializers/simple_form_bootstrap.rb
|
|
367
366
|
- config/locales/simple_form.en.yml
|
|
368
367
|
- config/routes.rb
|
|
369
|
-
- db/migrate/20170324221936_create_users.rb
|
|
370
368
|
- db/migrate/20190807231505_create_impersonations.rb
|
|
371
369
|
- lib/tasks/ucb_rails_user_tasks.rake
|
|
370
|
+
- lib/templates/db/create_users.rb
|
|
372
371
|
- lib/templates/erb/scaffold/_form.html.erb
|
|
373
372
|
- lib/ucb_rails_user.rb
|
|
374
373
|
- lib/ucb_rails_user/engine.rb
|
|
@@ -393,7 +392,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
393
392
|
- !ruby/object:Gem::Version
|
|
394
393
|
version: '0'
|
|
395
394
|
requirements: []
|
|
396
|
-
rubygems_version: 3.
|
|
395
|
+
rubygems_version: 3.4.20
|
|
397
396
|
signing_key:
|
|
398
397
|
specification_version: 4
|
|
399
398
|
summary: Rails engine for UCB user accounts
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
class UcbRailsUser::User < ActiveRecord::Base
|
|
2
|
-
include UcbRailsUser::Concerns::UserConcerns
|
|
3
|
-
|
|
4
|
-
# Don't add anything more here - any logic for the User class should go into
|
|
5
|
-
# UserConcerns. This will make it much easier for host apps to customize
|
|
6
|
-
# behavior if they need to
|
|
7
|
-
# http://guides.rubyonrails.org/engines.html#implementing-decorator-pattern-using-activesupport-concern
|
|
8
|
-
end
|
|
File without changes
|