lato_users 3.0.4 → 3.0.6
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
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: dcee2149bbb4d75dd166fce3e2008f9bdcebc58c9cc9c53a81beb1f7be78b412
|
|
4
|
+
data.tar.gz: 94f6f53942fca11cd59c28f82fc76a988de53e1f294f66f7ea35b90797726058
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 7748a34ffd5f3de2271bb42821fdc3f06a5d78bfe38ae321647862970ecf3ff98e1dc0b462435951734710d2e586da2aa0eab36808c541dfcf8db2b81528352a
|
|
7
|
+
data.tar.gz: f4a1bf6ea28450625008191e10132d3266b4cb832086bc183c4e3d6d6a5b61fdd6172d0cb26666cea76a85deaa891b5b33e3e08bb24a4d7ee8a3ae60b7579aae
|
|
@@ -55,6 +55,8 @@ module LatoUsers
|
|
|
55
55
|
@user = Lato::User.find(params[:id])
|
|
56
56
|
@user.destroy
|
|
57
57
|
redirect_to users_path
|
|
58
|
+
rescue ActiveRecord::InvalidForeignKey
|
|
59
|
+
redirect_to users_path, alert: I18n.t('lato_users.cannot_delete_foreign_key')
|
|
58
60
|
end
|
|
59
61
|
|
|
60
62
|
def resend_verification_email
|
|
@@ -97,11 +99,29 @@ module LatoUsers
|
|
|
97
99
|
private
|
|
98
100
|
|
|
99
101
|
def user_params
|
|
100
|
-
|
|
102
|
+
permission_keys = @available_admin_permissions.map { |permission| permission[:name] }
|
|
103
|
+
params.require(:user).permit(:email, :first_name, :last_name, :password, :password_confirmation, *permission_keys)
|
|
101
104
|
end
|
|
102
105
|
|
|
106
|
+
# Discover admin permissions on Lato::User by column naming convention.
|
|
107
|
+
# Each engine (lato_cms, lato_spaces, ...) adds its own column:
|
|
108
|
+
# - `lato_*_admin` -> boolean, rendered as a checkbox
|
|
109
|
+
# - `lato_*_admin_role` -> integer enum, rendered as a select
|
|
103
110
|
def load_available_admin_permissions
|
|
104
|
-
@available_admin_permissions ||= Lato::User.
|
|
111
|
+
@available_admin_permissions ||= Lato::User.column_names.filter_map do |name|
|
|
112
|
+
if name.match?(/\Alato_.+_admin\z/)
|
|
113
|
+
{ name: name, type: :boolean }
|
|
114
|
+
elsif name.match?(/\Alato_.+_admin_role\z/)
|
|
115
|
+
{ name: name, type: :enum, options: admin_permission_options(name) }
|
|
116
|
+
end
|
|
117
|
+
end
|
|
118
|
+
end
|
|
119
|
+
|
|
120
|
+
# Enum options are owned by the engine that defines the column, exposed as a
|
|
121
|
+
# `Lato::User.<column>_options` class method returning [[label, value], ...].
|
|
122
|
+
def admin_permission_options(name)
|
|
123
|
+
options_method = "#{name}_options"
|
|
124
|
+
Lato::User.respond_to?(options_method) ? Lato::User.public_send(options_method) : []
|
|
105
125
|
end
|
|
106
126
|
end
|
|
107
127
|
end
|
|
@@ -79,8 +79,15 @@ user ||= Lato::User.new
|
|
|
79
79
|
<div class="accordion-body">
|
|
80
80
|
<div class="row">
|
|
81
81
|
<% @available_admin_permissions.each_with_index do |permission, index| %>
|
|
82
|
-
|
|
83
|
-
|
|
82
|
+
<% is_enum = permission[:type] == :enum %>
|
|
83
|
+
<div class="<%= is_enum ? 'col-12' : 'col-12 col-md-6' %> <%= 'mb-3' unless index == @available_admin_permissions.size - 1 %>">
|
|
84
|
+
<% label = Lato::User.human_attribute_name(permission[:name]) %>
|
|
85
|
+
<% if is_enum %>
|
|
86
|
+
<%= lato_form_item_label form, permission[:name].to_sym, label %>
|
|
87
|
+
<%= lato_form_item_input_select form, permission[:name].to_sym, permission[:options] %>
|
|
88
|
+
<% else %>
|
|
89
|
+
<%= lato_form_item_input_check form, permission[:name].to_sym, label %>
|
|
90
|
+
<% end %>
|
|
84
91
|
</div>
|
|
85
92
|
<% end %>
|
|
86
93
|
</div>
|
data/config/locales/en.yml
CHANGED
|
@@ -11,6 +11,7 @@ en:
|
|
|
11
11
|
cta_confirm: Confirm
|
|
12
12
|
cta_delete_confirm: Are you sure you want to delete this user?
|
|
13
13
|
cannot_delete_self: You cannot delete your own user account.
|
|
14
|
+
cannot_delete_foreign_key: Cannot delete the user because it is linked to one or more records in other tables. Remove or update the linked records before proceeding with the deletion.
|
|
14
15
|
account_informations: Account Informations
|
|
15
16
|
email_verification: "Email Verification"
|
|
16
17
|
email_verified: "Email Verified"
|
data/config/locales/it.yml
CHANGED
|
@@ -11,6 +11,7 @@ it:
|
|
|
11
11
|
cta_confirm: Conferma
|
|
12
12
|
cta_delete_confirm: Sei sicuro di voler eliminare questo utente?
|
|
13
13
|
cannot_delete_self: Non puoi eliminare il tuo account utente.
|
|
14
|
+
cannot_delete_foreign_key: Impossibile eliminare l'utente perché è collegato ad uno o più record in altre tabelle. Rimuovi o aggiorna i record collegati prima di procedere con l'eliminazione.
|
|
14
15
|
account_informations: Informazioni Account
|
|
15
16
|
email_verification: "Verifica Email"
|
|
16
17
|
email_verified: "Email Verificata"
|
data/lib/lato_users/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: lato_users
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 3.0.
|
|
4
|
+
version: 3.0.6
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Gregorio Galante
|
|
8
|
-
autorequire:
|
|
9
8
|
bindir: bin
|
|
10
9
|
cert_chain: []
|
|
11
|
-
date:
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
12
11
|
dependencies:
|
|
13
12
|
- !ruby/object:Gem::Dependency
|
|
14
13
|
name: rails
|
|
@@ -88,7 +87,6 @@ licenses:
|
|
|
88
87
|
metadata:
|
|
89
88
|
homepage_uri: https://github.com/Lato-org/lato_users
|
|
90
89
|
source_code_uri: https://github.com/Lato-org/lato_users
|
|
91
|
-
post_install_message:
|
|
92
90
|
rdoc_options: []
|
|
93
91
|
require_paths:
|
|
94
92
|
- lib
|
|
@@ -103,8 +101,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
103
101
|
- !ruby/object:Gem::Version
|
|
104
102
|
version: '0'
|
|
105
103
|
requirements: []
|
|
106
|
-
rubygems_version:
|
|
107
|
-
signing_key:
|
|
104
|
+
rubygems_version: 4.0.9
|
|
108
105
|
specification_version: 4
|
|
109
106
|
summary: Another engine for Lato projects
|
|
110
107
|
test_files: []
|