ucb_rails_user 8.1.0 → 9.1.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 +20 -2
- data/app/assets/javascripts/ucb_rails_user/ucb_rails_user.js +0 -56
- data/app/assets/stylesheets/ucb_rails_user/components/impersonations.css +26 -0
- data/app/assets/stylesheets/ucb_rails_user/components/users_table.css +52 -3
- data/app/assets/stylesheets/ucb_rails_user/typeahead_tweaks.css +51 -0
- data/app/controllers/concerns/ucb_rails_user/users_controller_concerns.rb +24 -5
- data/app/views/ucb_rails_user/impersonations/index.html.erb +17 -5
- data/app/views/ucb_rails_user/users/_user.html.erb +1 -3
- data/app/views/ucb_rails_user/users/edit.html.erb +4 -2
- data/app/views/ucb_rails_user/users/impersonate_search.html.erb +25 -0
- data/app/views/ucb_rails_user/users/index.html.erb +115 -30
- data/app/views/ucb_rails_user/users/new.html.erb +15 -17
- data/app/views/ucb_rails_user/users/search.html.erb +15 -0
- data/config/importmap.rb +2 -0
- data/lib/ucb_rails_user/configuration/cas.rb +6 -7
- data/lib/ucb_rails_user/engine.rb +3 -2
- data/lib/ucb_rails_user/spec_helpers.rb +1 -1
- data/lib/ucb_rails_user/version.rb +1 -1
- data/lib/ucb_rails_user.rb +1 -0
- metadata +78 -64
- data/app/assets/javascripts/ucb_rails_user/datatables.js +0 -16891
- data/app/assets/javascripts/ucb_rails_user/esm/bloodhound.js +0 -953
- data/app/assets/javascripts/ucb_rails_user/esm/datatables.js +0 -28437
- data/app/assets/javascripts/ucb_rails_user/esm/typeahead.js +0 -1538
- data/app/assets/javascripts/ucb_rails_user/typeahead.bundle.js +0 -2451
- data/app/assets/stylesheets/ucb_rails_user/pagy_tailwind.css +0 -21
- data/app/assets/stylesheets/ucb_rails_user/typeahead_tweaks.sass +0 -43
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 75e8941c6eeaa787837b82537e117f7d22b3e0079123184f9d5f14efa6da7591
|
|
4
|
+
data.tar.gz: a1596b62abdff937aec92813bb61374350b6c9cd9a08c01317c0f6749929fda8
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: f661aad5319ba644f93195afdc2737ca7db8e5c11d9d56330ea4440e3dedc52a9fb0f71d67dafd2fde1a433c294e6452afc378aa5cac6bbb309d201baa3f8045
|
|
7
|
+
data.tar.gz: 752153a3da59b7254ab0bb1956f07539e1883f051c04ece5d1667c43dac46592bb528a1980235b45d80fafcb95f1f73bded8fa96c41de1830d8a89a148311d48
|
data/README.md
CHANGED
|
@@ -89,7 +89,23 @@ And in `application.js` add this line:
|
|
|
89
89
|
//= require ucb_rails_user/scripts
|
|
90
90
|
```
|
|
91
91
|
|
|
92
|
-
9.
|
|
92
|
+
9. Enable Turbo (required for admin user search functionality)
|
|
93
|
+
|
|
94
|
+
The admin user search uses Turbo Frames for seamless searching without page reloads. Add this to your application layout (typically `app/views/layouts/application.html.erb`):
|
|
95
|
+
|
|
96
|
+
```erb
|
|
97
|
+
<%= turbo_include_tags %>
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
Also update any `data-turbolinks-track` attributes to use `data-turbo-track` instead:
|
|
101
|
+
|
|
102
|
+
```erb
|
|
103
|
+
<%= stylesheet_link_tag "application", "data-turbo-track": "reload" %>
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
If your app doesn't already include Turbo, make sure the `turbo-rails` gem is in your Gemfile (it's included as a dependency of this gem).
|
|
107
|
+
|
|
108
|
+
10. Restart your host app as usual
|
|
93
109
|
|
|
94
110
|
You should be able to access the following routes:
|
|
95
111
|
|
|
@@ -131,7 +147,7 @@ resources :users, controller: "ucb_rails_user/users", path: "backend/users", as:
|
|
|
131
147
|
|
|
132
148
|
## Session Managers
|
|
133
149
|
|
|
134
|
-
Authentication during login is handled by UCB's central auth system and this gem uses
|
|
150
|
+
Authentication during login is handled by UCB's central auth system and this gem uses [omniauth-cas](https://github.com/dlindahl/omniauth-cas) (OmniAuth 2.x) to manage the handshake. Login starts at `login_path` (`GET /login`), which renders a page with a CSRF-protected button that POSTs to `/auth/cas`. Always link to `login_path`, never to `/auth/cas` directly: OmniAuth 2 rejects GET requests there. Once that is completed, we're handed the LDAP uid of the authenticated user, and, by default, this gem will attempt to pull the user's employee data and create or update a `User` record for them in the local database.
|
|
135
151
|
|
|
136
152
|
This behavior can be customized by writing your own user session manager. There are two steps to do this:
|
|
137
153
|
|
|
@@ -290,3 +306,5 @@ There is a new session timeout gem that can be used as well. It has a nice Javas
|
|
|
290
306
|
## Version 8+
|
|
291
307
|
|
|
292
308
|
This version removes both the emailing setup functionality as well as the error reporting functionality. Those are both in the [UcbRailsDefaults] (https://gitlab.com/ucb-bit/cad/aa/ucb_rails_defaults) gem. This gem's dependencies have been slimmed down so that only the basics to run the gem are required. This makes it easier to upgrade the including apps.
|
|
309
|
+
|
|
310
|
+
Versions 8.0.x use the new standard of Turbo, importmaps, and propshaft. The 8.0.x versions do not have the latest CAS upgrades in them and are used for Rails 8 apps that are in maintenance mode.
|
|
@@ -35,20 +35,6 @@ var addDatatablesToUsersTable = function () {
|
|
|
35
35
|
$('.ucb-rails-users-table-wrapper #DataTables_Table_0_filter').append(addNewHtml)
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
-
var resetImpersonateButton = function() {
|
|
39
|
-
var targetId = $('#ucb_rails_user_impersonation_target_id').val()
|
|
40
|
-
if (targetId != null && targetId.toString().length > 0) {
|
|
41
|
-
$('input[data-impersonate-button]').removeAttr('disabled')
|
|
42
|
-
} else {
|
|
43
|
-
$('input[data-impersonate-button]').attr('disabled', 'disabled')
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
var clearImpersonateSelection = function() {
|
|
48
|
-
$('#ucb_rails_user_impersonation_target_id').val('')
|
|
49
|
-
resetImpersonateButton()
|
|
50
|
-
}
|
|
51
|
-
|
|
52
38
|
$( window ).on("load", function() {
|
|
53
39
|
// the datatable calling was failing intermittently, but adding the timeout
|
|
54
40
|
// seemed to fix it, so ¯\_(ツ)_/¯
|
|
@@ -58,46 +44,4 @@ $( window ).on("load", function() {
|
|
|
58
44
|
$('.search-results').hide()
|
|
59
45
|
$('.ucb-rails-user-loader').show()
|
|
60
46
|
})
|
|
61
|
-
|
|
62
|
-
var usersSource = new Bloodhound({
|
|
63
|
-
datumTokenizer: Bloodhound.tokenizers.obj.whitespace('value'),
|
|
64
|
-
queryTokenizer: Bloodhound.tokenizers.whitespace,
|
|
65
|
-
remote: {
|
|
66
|
-
url: '/admin/users/impersonate_search?q=%QUERY',
|
|
67
|
-
wildcard: '%QUERY'
|
|
68
|
-
}
|
|
69
|
-
});
|
|
70
|
-
|
|
71
|
-
$('#ucb_rails_user_impersonation_target').typeahead(null, {
|
|
72
|
-
name: 'users',
|
|
73
|
-
source: usersSource,
|
|
74
|
-
display: 'name',
|
|
75
|
-
limit: 7, // any higher than this, and the results don't display properly
|
|
76
|
-
templates: {
|
|
77
|
-
empty: [
|
|
78
|
-
'<div class="empty-message">',
|
|
79
|
-
'No match found',
|
|
80
|
-
'</div>'
|
|
81
|
-
].join('\n'),
|
|
82
|
-
suggestion: function (data) {
|
|
83
|
-
return '<div><strong>' + data.name + '</strong> (' + data.uid + ')</div>'
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
});
|
|
87
|
-
|
|
88
|
-
$('#ucb_rails_user_impersonation_target').keyup(function(event) {
|
|
89
|
-
if ($(event.target).val().length == 0) {
|
|
90
|
-
clearImpersonateSelection()
|
|
91
|
-
}
|
|
92
|
-
})
|
|
93
|
-
|
|
94
|
-
$('#ucb_rails_user_impersonation_target').bind('typeahead:open', function(event, suggestion) {
|
|
95
|
-
clearImpersonateSelection()
|
|
96
|
-
})
|
|
97
|
-
|
|
98
|
-
$('#ucb_rails_user_impersonation_target').bind('typeahead:select', function(event, suggestion) {
|
|
99
|
-
$('#ucb_rails_user_impersonation_target_id').val(suggestion.id)
|
|
100
|
-
resetImpersonateButton()
|
|
101
|
-
})
|
|
102
|
-
|
|
103
47
|
})
|
|
@@ -10,3 +10,29 @@
|
|
|
10
10
|
.recent-impersonations li {
|
|
11
11
|
list-style-type: none;
|
|
12
12
|
font-size: 110%; }
|
|
13
|
+
|
|
14
|
+
.impersonate_search_results_container {
|
|
15
|
+
margin-top: 10px;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
.impersonate_result_list {
|
|
19
|
+
list-style: none;
|
|
20
|
+
padding: 0;
|
|
21
|
+
margin-top: 10px;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
.impersonate_result_list_item {
|
|
25
|
+
padding: 8px;
|
|
26
|
+
border-bottom: 1px solid #eee;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
.impersonate_no_results_found {
|
|
30
|
+
margin-top: 10px;
|
|
31
|
+
color: #999;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
.impersonate_before_search {
|
|
35
|
+
margin-top: 10px;
|
|
36
|
+
color: #666;
|
|
37
|
+
}
|
|
38
|
+
|
|
@@ -1,13 +1,26 @@
|
|
|
1
1
|
.ucb-rails-users-table-header {
|
|
2
2
|
margin-top: 16px;
|
|
3
|
-
margin-bottom:
|
|
3
|
+
margin-bottom: 8px; }
|
|
4
4
|
|
|
5
5
|
.ucb-rails-users-table-header a {
|
|
6
|
-
margin-top:
|
|
6
|
+
margin-top: 0px; }
|
|
7
|
+
|
|
8
|
+
.ucb-rails-users-table-header form {
|
|
9
|
+
display: flex !important;
|
|
10
|
+
gap: 15px;
|
|
11
|
+
align-items: center;
|
|
12
|
+
flex-direction: row;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
.ucb-rails-users-table-header form span,
|
|
16
|
+
.ucb-rails-users-table-header form select,
|
|
17
|
+
.ucb-rails-users-table-header form input {
|
|
18
|
+
vertical-align: middle;
|
|
19
|
+
}
|
|
7
20
|
|
|
8
21
|
table.ucb-rails-users-table {
|
|
9
22
|
border-spacing: 0px;
|
|
10
|
-
margin-top:
|
|
23
|
+
margin-top: 8px;
|
|
11
24
|
}
|
|
12
25
|
|
|
13
26
|
table.ucb-rails-users-table th {
|
|
@@ -52,3 +65,39 @@ h1 {
|
|
|
52
65
|
padding-left: 10px;
|
|
53
66
|
padding-right: 10px;
|
|
54
67
|
}
|
|
68
|
+
|
|
69
|
+
.user_sort {
|
|
70
|
+
text-decoration: none;
|
|
71
|
+
color: inherit;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
.user_form_container {
|
|
75
|
+
margin-top: 10px;
|
|
76
|
+
overflow: auto;
|
|
77
|
+
margin-bottom: 10px;
|
|
78
|
+
vertical-align: middle;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
.user_form_base_style {
|
|
82
|
+
display: flex;
|
|
83
|
+
gap: 10px;
|
|
84
|
+
align-items:
|
|
85
|
+
center; flex-grow: 1;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
.user_form_return_count {
|
|
89
|
+
float: left;
|
|
90
|
+
padding-right: 15px;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
.user_form_search_box {
|
|
94
|
+
float: left;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
.user_form_add_user_link {
|
|
98
|
+
float: right;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
.user_turbo_frame_users {
|
|
102
|
+
margin-bottom: 10px;
|
|
103
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Ironically, Bootstrap 3.x breaks styles in typeahead.js - these styles provide the needed repair
|
|
3
|
+
* source: https://gist.github.com/AntMooreWebDev/2f7e423a11bc74359323995df4494167
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
.twitter-typeahead .tt-query,
|
|
7
|
+
.twitter-typeahead .tt-hint {
|
|
8
|
+
margin-bottom: 0;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
.twitter-typeahead {
|
|
12
|
+
display: block !important;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
.tt-menu {
|
|
16
|
+
/* make this wide enough to accomodate the org unit code and name */
|
|
17
|
+
width: 400px;
|
|
18
|
+
min-width: 160px;
|
|
19
|
+
margin-top: 2px;
|
|
20
|
+
padding: 5px;
|
|
21
|
+
background-color: #ffffff;
|
|
22
|
+
border: 1px solid #cccccc;
|
|
23
|
+
border: 1px solid rgba(0, 0, 0, 0.15);
|
|
24
|
+
border-radius: 4px;
|
|
25
|
+
-webkit-box-shadow: 0 6px 12px rgba(0, 0, 0, 0.175);
|
|
26
|
+
box-shadow: 0 6px 12px rgba(0, 0, 0, 0.175);
|
|
27
|
+
background-clip: padding-box;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
.tt-suggestion {
|
|
31
|
+
display: block;
|
|
32
|
+
padding: 3px 20px;
|
|
33
|
+
width: 100%;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
.tt-suggestion.tt-selectable {
|
|
37
|
+
margin: 5px 0px 5px 0px;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
.tt-suggestion.tt-cursor {
|
|
41
|
+
color: #fff;
|
|
42
|
+
background-color: #428bca;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
.tt-suggestion.tt-cursor a {
|
|
46
|
+
color: #fff;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
.tt-suggestion p {
|
|
50
|
+
margin: 0;
|
|
51
|
+
}
|
|
@@ -9,7 +9,20 @@ module UcbRailsUser::UsersControllerConcerns
|
|
|
9
9
|
end
|
|
10
10
|
|
|
11
11
|
def index
|
|
12
|
-
@
|
|
12
|
+
@sort = params[:sort] || "last_name"
|
|
13
|
+
@sort_dir = params[:dir] || "asc"
|
|
14
|
+
|
|
15
|
+
# Build the query
|
|
16
|
+
users = if !params[:query].blank?
|
|
17
|
+
search_user_table(params[:query])
|
|
18
|
+
else
|
|
19
|
+
UcbRailsUser.user_class.all
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
# Apply sorting
|
|
23
|
+
users = users.order("#{@sort} #{@sort_dir}")
|
|
24
|
+
|
|
25
|
+
@pagy, @users = pagy(users, limit: params[:count])
|
|
13
26
|
end
|
|
14
27
|
|
|
15
28
|
def search
|
|
@@ -24,8 +37,12 @@ module UcbRailsUser::UsersControllerConcerns
|
|
|
24
37
|
end
|
|
25
38
|
|
|
26
39
|
def impersonate_search
|
|
27
|
-
|
|
28
|
-
|
|
40
|
+
@query = params[:q]
|
|
41
|
+
@results = if @query.present? && @query.length >= 2
|
|
42
|
+
UcbRailsUser::UserSearch.find_users_by_name(@query)
|
|
43
|
+
else
|
|
44
|
+
[]
|
|
45
|
+
end
|
|
29
46
|
end
|
|
30
47
|
|
|
31
48
|
def edit
|
|
@@ -91,7 +108,6 @@ module UcbRailsUser::UsersControllerConcerns
|
|
|
91
108
|
@lps_existing_uids = UcbRailsUser.user_class.where(ldap_uid: uid_strings).pluck(:uid)
|
|
92
109
|
render 'ucb_rails_user/lps/search'
|
|
93
110
|
end
|
|
94
|
-
|
|
95
111
|
end
|
|
96
112
|
|
|
97
113
|
def typeahead_search
|
|
@@ -111,6 +127,10 @@ module UcbRailsUser::UsersControllerConcerns
|
|
|
111
127
|
|
|
112
128
|
private
|
|
113
129
|
|
|
130
|
+
def search_user_table(query)
|
|
131
|
+
UcbRailsUser.user_class.where('lower(first_name) like lower(:q) or lower(last_name) like lower(:q) or lower(email) like lower(:q) or lower(alternate_email) like lower(:q) or ldap_uid like :q or ldap_uid like :q or employee_id like :q', q: '%' + query + '%')
|
|
132
|
+
end
|
|
133
|
+
|
|
114
134
|
def user_params(extra_params = [])
|
|
115
135
|
params.require(:user).permit([
|
|
116
136
|
:superuser_flag,
|
|
@@ -130,5 +150,4 @@ module UcbRailsUser::UsersControllerConcerns
|
|
|
130
150
|
def find_user
|
|
131
151
|
@user ||= UcbRailsUser.user_class.find(params.fetch(:id))
|
|
132
152
|
end
|
|
133
|
-
|
|
134
153
|
end
|
|
@@ -6,10 +6,22 @@
|
|
|
6
6
|
</div>
|
|
7
7
|
<% else %>
|
|
8
8
|
<div class="impersonation-form">
|
|
9
|
-
<%=
|
|
10
|
-
<%= f.
|
|
11
|
-
<%= f.
|
|
12
|
-
|
|
9
|
+
<%= form_with url: admin_user_impersonate_search_path, method: :get, data: { turbo_frame: "search_results" } do |f| %>
|
|
10
|
+
<%= f.label :q, "Search for user:" %>
|
|
11
|
+
<%= f.search_field :q, placeholder: "Enter name...", oninput: "
|
|
12
|
+
clearTimeout(window.impersonateSearchTimer);
|
|
13
|
+
window.impersonateSearchTimer = setTimeout(() => {
|
|
14
|
+
if (this.value.length >= 2) {
|
|
15
|
+
this.form.requestSubmit();
|
|
16
|
+
}
|
|
17
|
+
}, 300);
|
|
18
|
+
" %>
|
|
19
|
+
<% end %>
|
|
20
|
+
|
|
21
|
+
<%= turbo_frame_tag "search_results" do %>
|
|
22
|
+
<div style="margin-top: 10px; color: #666;">
|
|
23
|
+
Type at least 2 characters to search for a user...
|
|
24
|
+
</div>
|
|
13
25
|
<% end %>
|
|
14
26
|
</div>
|
|
15
27
|
<% end %>
|
|
@@ -20,7 +32,7 @@
|
|
|
20
32
|
<ul>
|
|
21
33
|
<% current_user.recent_impersonations.each do |imp| %>
|
|
22
34
|
<li>
|
|
23
|
-
<%= link_to full_name_with_uid(imp.target),
|
|
35
|
+
<%= link_to full_name_with_uid(imp.target), admin_impersonations_path(ucb_rails_user_impersonation: { target_id: imp.target.id }), data: { turbo_method: :post, turbo_frame: "_top" } %>
|
|
24
36
|
</li>
|
|
25
37
|
<% end %>
|
|
26
38
|
</ul>
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
<%= turbo_frame_tag "users" do %>
|
|
2
1
|
<tr id="user_<%=user.id%>" class="user">
|
|
3
2
|
<td><%= checkmark(user.superuser?) %></td>
|
|
4
3
|
<td><%= checkmark(user.inactive?) %></td>
|
|
@@ -9,10 +8,9 @@
|
|
|
9
8
|
<td class="min"><%= user.ldap_uid %></td>
|
|
10
9
|
<td class="min"><%= user.employee_id %></td>
|
|
11
10
|
<td>
|
|
12
|
-
<%= link_to 'edit', edit_admin_user_path(user), class: 'btn btn-
|
|
11
|
+
<%= link_to 'edit', edit_admin_user_path(user), class: 'btn btn-primary', id: dom_id(user, 'edit'), role: 'button', data: { turbo_frame: "users" } %>
|
|
13
12
|
</td>
|
|
14
13
|
<td>
|
|
15
14
|
<%= button_to 'delete', admin_user_path(user), method: :delete, data: { confirm: "Are you sure?" }, class: "btn btn-danger" %>
|
|
16
15
|
</td>
|
|
17
16
|
</tr>
|
|
18
|
-
<% end %>
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
<%= turbo_frame_tag "search_results" do %>
|
|
2
|
+
<% if @results.any? %>
|
|
3
|
+
<div class="impersonate_search_results_container">
|
|
4
|
+
<strong>Search results for "<%= @query %>":</strong>
|
|
5
|
+
<ul class="impersonate_result_list">
|
|
6
|
+
<% @results.each do |user| %>
|
|
7
|
+
<li class="impersonate_result_list_item">
|
|
8
|
+
<%= link_to admin_impersonations_path(ucb_rails_user_impersonation: { target_id: user.id }), data: { turbo_method: :post, turbo_frame: "_top" }, style: "text-decoration: none; color: inherit; display: block;" do %>
|
|
9
|
+
<strong><%= user.full_name %></strong>
|
|
10
|
+
<span style="color: #666; margin-left: 10px;">(<%= user.ldap_uid %>)</span>
|
|
11
|
+
<% end %>
|
|
12
|
+
</li>
|
|
13
|
+
<% end %>
|
|
14
|
+
</ul>
|
|
15
|
+
</div>
|
|
16
|
+
<% elsif @query.present? && @query.length >= 2 %>
|
|
17
|
+
<div class="impersonate_no_results_found">
|
|
18
|
+
No users found matching "<%= @query %>"
|
|
19
|
+
</div
|
|
20
|
+
<% else %>
|
|
21
|
+
<div class="impersonate_before_search">
|
|
22
|
+
Type at least 2 characters to search for a user...
|
|
23
|
+
</div>
|
|
24
|
+
<% end %>
|
|
25
|
+
<% end %>
|
|
@@ -1,34 +1,119 @@
|
|
|
1
|
-
<div class="ucb-rails-users-table-header
|
|
1
|
+
<div class="ucb-rails-users-table-header">
|
|
2
2
|
<h1>Users</h1>
|
|
3
3
|
</div>
|
|
4
4
|
|
|
5
|
-
<%=
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
<
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
</
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
5
|
+
<%= turbo_frame_tag "users" do %>
|
|
6
|
+
<% if flash[:notice] || flash[:error] || flash[:alert] %>
|
|
7
|
+
<div class="user_turbo_frame_users">
|
|
8
|
+
<% if flash[:notice] %>
|
|
9
|
+
<div class="alert alert-info"><%= flash[:notice] %></div>
|
|
10
|
+
<% end %>
|
|
11
|
+
<% if flash[:error] %>
|
|
12
|
+
<div class="alert alert-danger"><%= flash[:error] %></div>
|
|
13
|
+
<% end %>
|
|
14
|
+
<% if flash[:alert] %>
|
|
15
|
+
<div class="alert alert-warning"><%= flash[:alert] %></div>
|
|
16
|
+
<% end %>
|
|
17
|
+
</div>
|
|
18
|
+
<% end %>
|
|
19
|
+
<div class="user_form_container">
|
|
20
|
+
<%= form_with url: "", method: :get, data: { turbo_frame: "users" }, class: "user_form_base_style" do |form| %>
|
|
21
|
+
<%= form.hidden_field :sort, value: @sort %>
|
|
22
|
+
<%= form.hidden_field :dir, value: @sort_dir %>
|
|
23
|
+
<div class="user_form_return_count">
|
|
24
|
+
Show <%= form.select :count, options_for_select([10, 25, 50, 100], selected: params[:count]), {}, { onchange: "this.form.requestSubmit()" } %>
|
|
25
|
+
</div>
|
|
26
|
+
<div class="user_form_search_box">
|
|
27
|
+
Search <%= form.search_field :query, value: params[:query], id: "user_search_field", placeholder: "Search users...", data: { turbo_permanent: true }, oninput: "
|
|
28
|
+
clearTimeout(window.searchTimer);
|
|
29
|
+
window.searchTimer = setTimeout(() => {
|
|
30
|
+
this.form.requestSubmit();
|
|
31
|
+
}, 300);
|
|
32
|
+
" %>
|
|
33
|
+
</div>
|
|
34
|
+
<% end %>
|
|
35
|
+
<div class="user_form_add_user_link">
|
|
36
|
+
<%= link_to "Add User", new_admin_user_path, class: "btn btn-primary" %>
|
|
37
|
+
</div>
|
|
33
38
|
</div>
|
|
34
|
-
|
|
39
|
+
<div class="table-responsive ucb-rails-users-table-wrapper">
|
|
40
|
+
<table class="table table-striped table-bordered table-hover ucb-rails-users-table">
|
|
41
|
+
<thead>
|
|
42
|
+
<tr>
|
|
43
|
+
<th class="min">
|
|
44
|
+
<%= link_to admin_users_path(sort: "superuser_flag", dir: @sort == "superuser_flag" && @sort_dir == "asc" ? "desc" : "asc", query: params[:query], count: params[:count]), data: { turbo_frame: "users" }, class: "user_sort" do %>
|
|
45
|
+
Superuser?
|
|
46
|
+
<% if @sort == "superuser_flag" %>
|
|
47
|
+
<%= @sort_dir == "asc" ? "▲" : "▼" %>
|
|
48
|
+
<% end %>
|
|
49
|
+
<% end %>
|
|
50
|
+
</th>
|
|
51
|
+
<th class="min">
|
|
52
|
+
<%= link_to admin_users_path(sort: "inactive_flag", dir: @sort == "inactive_flag" && @sort_dir == "asc" ? "desc" : "asc", query: params[:query], count: params[:count]), data: { turbo_frame: "users" }, class: "user_sort" do %>
|
|
53
|
+
Inactive?
|
|
54
|
+
<% if @sort == "inactive_flag" %>
|
|
55
|
+
<%= @sort_dir == "asc" ? "▲" : "▼" %>
|
|
56
|
+
<% end %>
|
|
57
|
+
<% end %>
|
|
58
|
+
</th>
|
|
59
|
+
<th>
|
|
60
|
+
<%= link_to admin_users_path(sort: "first_name", dir: @sort == "first_name" && @sort_dir == "asc" ? "desc" : "asc", query: params[:query], count: params[:count]), data: { turbo_frame: "users" }, class: "user_sort" do %>
|
|
61
|
+
First Name
|
|
62
|
+
<% if @sort == "first_name" %>
|
|
63
|
+
<%= @sort_dir == "asc" ? "▲" : "▼" %>
|
|
64
|
+
<% end %>
|
|
65
|
+
<% end %>
|
|
66
|
+
</th>
|
|
67
|
+
<th>
|
|
68
|
+
<%= link_to admin_users_path(sort: "last_name", dir: @sort == "last_name" && @sort_dir == "asc" ? "desc" : "asc", query: params[:query], count: params[:count]), data: { turbo_frame: "users" }, class: "user_sort" do %>
|
|
69
|
+
Last Name
|
|
70
|
+
<% if @sort == "last_name" %>
|
|
71
|
+
<%= @sort_dir == "asc" ? "▲" : "▼" %>
|
|
72
|
+
<% end %>
|
|
73
|
+
<% end %>
|
|
74
|
+
</th>
|
|
75
|
+
<th>
|
|
76
|
+
<%= link_to admin_users_path(sort: "email", dir: @sort == "email" && @sort_dir == "asc" ? "desc" : "asc", query: params[:query], count: params[:count]), data: { turbo_frame: "users" }, class: "user_sort" do %>
|
|
77
|
+
Email
|
|
78
|
+
<% if @sort == "email" %>
|
|
79
|
+
<%= @sort_dir == "asc" ? "▲" : "▼" %>
|
|
80
|
+
<% end %>
|
|
81
|
+
<% end %>
|
|
82
|
+
</th>
|
|
83
|
+
<th class="dt">
|
|
84
|
+
<%= link_to admin_users_path(sort: "last_login_at", dir: @sort == "last_login_at" && @sort_dir == "asc" ? "desc" : "asc", query: params[:query], count: params[:count]), data: { turbo_frame: "users" }, class: "user_sort" do %>
|
|
85
|
+
Last Login
|
|
86
|
+
<% if @sort == "last_login_at" %>
|
|
87
|
+
<%= @sort_dir == "asc" ? "▲" : "▼" %>
|
|
88
|
+
<% end %>
|
|
89
|
+
<% end %>
|
|
90
|
+
</th>
|
|
91
|
+
<th>
|
|
92
|
+
<%= link_to admin_users_path(sort: "ldap_uid", dir: @sort == "ldap_uid" && @sort_dir == "asc" ? "desc" : "asc", query: params[:query], count: params[:count]), data: { turbo_frame: "users" }, class: "user_sort" do %>
|
|
93
|
+
UID
|
|
94
|
+
<% if @sort == "ldap_uid" %>
|
|
95
|
+
<%= @sort_dir == "asc" ? "▲" : "▼" %>
|
|
96
|
+
<% end %>
|
|
97
|
+
<% end %>
|
|
98
|
+
</th>
|
|
99
|
+
<th>
|
|
100
|
+
<%= link_to admin_users_path(sort: "employee_id", dir: @sort == "employee_id" && @sort_dir == "asc" ? "desc" : "asc", query: params[:query], count: params[:count]), data: { turbo_frame: "users" }, class: "user_sort" do %>
|
|
101
|
+
Employee ID
|
|
102
|
+
<% if @sort == "employee_id" %>
|
|
103
|
+
<%= @sort_dir == "asc" ? "▲" : "▼" %>
|
|
104
|
+
<% end %>
|
|
105
|
+
<% end %>
|
|
106
|
+
</th>
|
|
107
|
+
<th class="min unsorted">Edit</th>
|
|
108
|
+
<th class="min unsorted">Delete</th>
|
|
109
|
+
</tr>
|
|
110
|
+
</thead>
|
|
111
|
+
<tbody class="highlight">
|
|
112
|
+
<%= render partial: "ucb_rails_user/users/user", collection: @users %>
|
|
113
|
+
</tbody>
|
|
114
|
+
</table>
|
|
115
|
+
<div class="ucb-rails-user">
|
|
116
|
+
<%= pagy_nav(@pagy, pagy_url_for: ->(page, pagy) { admin_users_path(page: page, count: params[:count], query: params[:query], sort: @sort, dir: @sort_dir) }).html_safe %>
|
|
117
|
+
</div>
|
|
118
|
+
</div>
|
|
119
|
+
<% end %>
|
|
@@ -1,19 +1,17 @@
|
|
|
1
|
-
|
|
1
|
+
<%= turbo_frame_tag "users" do %>
|
|
2
|
+
<h2>Add New User</h2>
|
|
2
3
|
|
|
3
|
-
<%= form_tag admin_user_search_path, method: :get,
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
<% end %>
|
|
10
|
-
|
|
11
|
-
<div class="ucb-rails-user-loader">
|
|
12
|
-
Loading...
|
|
13
|
-
</div>
|
|
14
|
-
|
|
15
|
-
<div class="search-results">
|
|
16
|
-
<% if @results %>
|
|
17
|
-
<%= render "results" %>
|
|
4
|
+
<%= form_tag admin_user_search_path, method: :get, class: "form-inline user-search-form" do %>
|
|
5
|
+
<%= text_field_tag :first_name, "", placeholder: "First name", class: "form-control" %>
|
|
6
|
+
<%= text_field_tag :last_name, "", placeholder: "Last name", class: "form-control" %>
|
|
7
|
+
<%= text_field_tag :employee_id, "", placeholder: "Employee ID", class: "form-control" %>
|
|
8
|
+
<%= submit_tag "Search", class: "btn btn-primary", data: { turbo_submits_with: "Searching..." } %>
|
|
9
|
+
<%= link_to "Cancel", admin_users_path, class: "btn btn-default" %>
|
|
18
10
|
<% end %>
|
|
19
|
-
|
|
11
|
+
|
|
12
|
+
<div class="search-results">
|
|
13
|
+
<% if @results %>
|
|
14
|
+
<%= render "results" %>
|
|
15
|
+
<% end %>
|
|
16
|
+
</div>
|
|
17
|
+
<% end %>
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
<%= turbo_frame_tag "users" do %>
|
|
2
|
+
<h2>Add New User</h2>
|
|
3
|
+
|
|
4
|
+
<%= form_tag admin_user_search_path, method: :get, class: "form-inline user-search-form" do %>
|
|
5
|
+
<%= text_field_tag :first_name, params[:first_name], placeholder: "First name", class: "form-control" %>
|
|
6
|
+
<%= text_field_tag :last_name, params[:last_name], placeholder: "Last name", class: "form-control" %>
|
|
7
|
+
<%= text_field_tag :employee_id, params[:employee_id], placeholder: "Employee ID", class: "form-control" %>
|
|
8
|
+
<%= submit_tag "Search", class: "btn btn-primary" %>
|
|
9
|
+
<%= link_to "Cancel", admin_users_path, class: "btn btn-default" %>
|
|
10
|
+
<% end %>
|
|
11
|
+
|
|
12
|
+
<div class="search-results">
|
|
13
|
+
<%= render "search_results" %>
|
|
14
|
+
</div>
|
|
15
|
+
<% end %>
|
data/config/importmap.rb
ADDED
|
@@ -15,15 +15,14 @@ module UcbRailsUser
|
|
|
15
15
|
|
|
16
16
|
def configure_omniauth
|
|
17
17
|
host_name = host
|
|
18
|
-
|
|
19
|
-
#
|
|
18
|
+
|
|
19
|
+
# OmniAuth 2: the request phase must be a POST carrying a valid CSRF token
|
|
20
|
+
# (CVE-2015-9284). Never add :get, and never disable request_validation_phase:
|
|
21
|
+
# omniauth-rails_csrf_protection wires it to Rails' forgery protection.
|
|
20
22
|
OmniAuth.config.allowed_request_methods = [:post]
|
|
21
23
|
OmniAuth.config.silence_get_warning = true
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
# This is safe because we're only allowing POST requests and CAS provides its own security
|
|
25
|
-
OmniAuth.config.request_validation_phase = nil
|
|
26
|
-
|
|
24
|
+
OmniAuth.config.logger = Rails.logger
|
|
25
|
+
|
|
27
26
|
Rails.application.config.middleware.use OmniAuth::Builder do
|
|
28
27
|
|
|
29
28
|
unless Rails.env.production?
|