lato_users 3.0.6 → 3.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: dcee2149bbb4d75dd166fce3e2008f9bdcebc58c9cc9c53a81beb1f7be78b412
4
- data.tar.gz: 94f6f53942fca11cd59c28f82fc76a988de53e1f294f66f7ea35b90797726058
3
+ metadata.gz: c1063de104b7327b8c11dcfda25fca09250eae9675ea5566464cc4502b77fcc5
4
+ data.tar.gz: cd039cafbdfb1860ae743216b4dc634e04073d7d380f965a4644f36d157a205e
5
5
  SHA512:
6
- metadata.gz: 7748a34ffd5f3de2271bb42821fdc3f06a5d78bfe38ae321647862970ecf3ff98e1dc0b462435951734710d2e586da2aa0eab36808c541dfcf8db2b81528352a
7
- data.tar.gz: f4a1bf6ea28450625008191e10132d3266b4cb832086bc183c4e3d6d6a5b61fdd6172d0cb26666cea76a85deaa891b5b33e3e08bb24a4d7ee8a3ae60b7579aae
6
+ metadata.gz: 16dc9f850c50020843f84bd4b1a2c8d53e40c8efc071bd52427b3ff70014b34458e29984e3fcc0af4987e74ea6ccb42d64ba22fee6e243032e65042613cb23bc
7
+ data.tar.gz: 6afabc5ccb14289c452dd8a99b25586152a482bc78aeff32b8cc483c0f27056af77d60a4f2b04919a04497d7f553be962141dceb4fff545a44521af070e0d64d
data/README.md CHANGED
@@ -2,7 +2,24 @@
2
2
 
3
3
  Manage application users on Lato projects.
4
4
 
5
+ ## Features
6
+
7
+ - Users: list (search, sort, pagination), create, edit, delete and detail page (account, email verification, security with authenticator/passkey state and latest signup/login logs, privacy and terms versions).
8
+ - Email verification: resend the verification email, verify or revoke manually.
9
+ - Passwords: set on creation (with a client-side generator based on `crypto.getRandomValues`) and "Force password update", which generates a random password, shows it **once** in the response and revokes all the user sessions.
10
+ - Permissions: edit the `lato_*_admin` / `lato_*_admin_role` flags of every installed Lato engine from the user form.
11
+ - Invitations: create, resend and delete invitations (accepted invitations cannot be deleted).
12
+ - Languages: `en` and `it`.
13
+
5
14
  ## Installation
15
+
16
+ Requires Rails 8.1.3.1 or newer in the 8.1 series and Lato 3.25.0 or newer. Existing applications must run `rails lato:install:migrations` (Lato session records) before deployment; previous sessions are invalidated.
17
+
18
+ Dependencies of the host application:
19
+
20
+ - A configured Action Mailer (verification and invitation emails).
21
+ - A working `Rails.cache` store (email semaphores and verification codes).
22
+
6
23
  Add required dependencies to your application's Gemfile:
7
24
 
8
25
  ```ruby
@@ -11,15 +28,16 @@ gem "lato"
11
28
  gem "lato_users"
12
29
  ```
13
30
 
14
- Install gem and run required tasks:
31
+ Install gem and migrations (adds the `lato_users_admin` column to `lato_users`):
15
32
 
16
33
  ```bash
17
34
  $ bundle
18
- $ rails lato_users:install:application
19
35
  $ rails lato_users:install:migrations
20
36
  $ rails db:migrate
21
37
  ```
22
38
 
39
+ `rails lato_users:install:application` is a no-op and is not required.
40
+
23
41
  Mount lato users routes on the **config/routes.rb** file:
24
42
 
25
43
  ```ruby
@@ -29,7 +47,7 @@ Rails.application.routes.draw do
29
47
  end
30
48
  ```
31
49
 
32
- Import Lato Scss on **app/assets/stylesheets/application.scss** file:
50
+ Import Lato Users styles on **app/assets/stylesheets/application.scss** file:
33
51
  ```scss
34
52
  @import 'lato_users/application';
35
53
 
@@ -43,6 +61,52 @@ import "lato_users/application";
43
61
  // ....
44
62
  ```
45
63
 
64
+ Add the menu entry (only for admins) in your navbar or sidebar partial; the engine activates `:lato_users` on its pages:
65
+
66
+ ```erb
67
+ <% if @session.user&.lato_users_admin %>
68
+ <%= lato_navbar_nav_item :lato_users, lato_users.root_path do %>Users<% end %>
69
+ <% end %>
70
+ ```
71
+
72
+ Make sure the host filters password parameters from logs (`config.filter_parameters` including `:passw`).
73
+
74
+ ## Routes
75
+
76
+ Mounted at the chosen path: `/` (redirects to `users`), `users` (+ `resend_verification_email`, `manual_verify_email`, `revoke_email_verification`, `force_update_password`) and `invitations` (+ `resend`).
77
+
78
+ ## Permissions
79
+
80
+ Access requires a Lato session and `lato_users_admin: true` on `Lato::User`. Grant the first one from seeds or console:
81
+
82
+ ```ruby
83
+ Lato::User.find_by!(email: "admin@example.com").update!(lato_users_admin: true)
84
+ ```
85
+
86
+ `lato_users_admin` is effectively a **super-admin** flag: it can grant any other engine's admin permission to any user. Protections: an admin cannot remove their own `lato_users_admin` nor delete their own account, and the last users admin can be neither demoted nor deleted. Non-admin requests are redirected to the Lato root (`403` for non-HTML formats).
87
+
88
+ Permissions of other engines are discovered by column name on `Lato::User`:
89
+
90
+ - `lato_*_admin`: boolean, rendered as a checkbox (`lato_users_admin`, `lato_settings_admin`, `lato_spaces_admin`, `lato_storage_admin`, ...).
91
+ - `lato_*_admin_role`: integer, rendered as a select. The owning engine must expose `Lato::User.<column>_options` returning `[[label, value], ...]` (for example `lato_cms_admin_role_options`); submitted values outside these options are rejected.
92
+
93
+ Labels come from `activerecord.attributes.lato/user.<column>`; this gem translates the official ones (`en`, `it`).
94
+
95
+ ## Security behaviour
96
+
97
+ - Users created by an admin are saved with the current privacy policy and terms versions, because `Lato::User` requires them; the admin is not the user's legal consent. Review this against your legal requirements.
98
+ - Passwords can only be set on creation. Existing users get a new password only through "Force password update" (shown once, never stored in flash or session; response is `no-store`).
99
+ - Changing the email of another user revokes that user's sessions (the admin's own sessions are kept). Lato itself revokes sessions on password change only.
100
+ - There is no audit log: admin actions are not recorded (to be handled by the host application).
101
+
102
+ ## Test
103
+
104
+ ```shell
105
+ $ bin/rails test
106
+ ```
107
+
108
+ Fixtures live in `test/fixtures/lato`; integration tests sign in with `authenticate_user` (`test/test_helper.rb`). Dummy seed login: `admin@mail.com` / `Password1!`.
109
+
46
110
  ## Development
47
111
 
48
112
  Clone repository, install dependencies, run migrations and start:
@@ -1 +1 @@
1
- console.log("Lato Users JS loaded");
1
+ // Lato Users JavaScript entry point (Stimulus controllers are registered through the importmap).
@@ -1,27 +1,65 @@
1
1
  import { Controller } from "@hotwired/stimulus"
2
2
 
3
+ const CHARACTER_CLASSES = [
4
+ "abcdefghijklmnopqrstuvwxyz",
5
+ "ABCDEFGHIJKLMNOPQRSTUVWXYZ",
6
+ "0123456789",
7
+ "!@#$%^&*"
8
+ ]
9
+
3
10
  export default class extends Controller {
4
11
  static targets = [
5
12
  "password",
6
13
  "passwordConfirmation",
7
- "generatedPassword"
14
+ "generatedPassword",
15
+ "status"
8
16
  ]
9
-
10
- connect() {
11
-
17
+
18
+ static values = {
19
+ length: { type: Number, default: 16 },
20
+ generatedMessage: String,
21
+ confirmMessage: String
12
22
  }
13
23
 
14
24
  generatePassword(event) {
15
25
  event.preventDefault()
16
- const length = 12
17
- const charset = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%^&*"
18
- let retVal = ""
19
- for (let i = 0, n = charset.length; i < length; ++i) {
20
- retVal += charset.charAt(Math.floor(Math.random() * n))
26
+ const password = this.buildPassword()
27
+
28
+ this.passwordTarget.value = password
29
+ this.passwordConfirmationTarget.value = password
30
+ this.generatedPasswordTarget.value = password
31
+ if (this.hasStatusTarget) this.statusTarget.textContent = this.generatedMessageValue
32
+ }
33
+
34
+ // The form opts out of Turbo (the response must render in place, see force_update_password), so it asks for confirmation itself.
35
+ confirmSubmit(event) {
36
+ if (!window.confirm(this.confirmMessageValue)) event.preventDefault()
37
+ }
38
+
39
+ // One character per class (password policies), the rest from the full charset, then shuffled.
40
+ buildPassword() {
41
+ const charset = CHARACTER_CLASSES.join("")
42
+ const chars = CHARACTER_CLASSES.map((characters) => this.pick(characters))
43
+ while (chars.length < this.lengthValue) chars.push(this.pick(charset))
44
+
45
+ for (let i = chars.length - 1; i > 0; i--) {
46
+ const j = this.randomInt(i + 1)
47
+ ;[chars[i], chars[j]] = [chars[j], chars[i]]
21
48
  }
22
-
23
- this.passwordTarget.value = retVal
24
- this.passwordConfirmationTarget.value = retVal
25
- this.generatedPasswordTarget.value = retVal
49
+ return chars.join("")
50
+ }
51
+
52
+ pick(characters) {
53
+ return characters.charAt(this.randomInt(characters.length))
54
+ }
55
+
56
+ // Uniform integer in [0, max) from a CSPRNG, rejecting the biased tail of the 32-bit range.
57
+ randomInt(max) {
58
+ const limit = Math.floor(0x100000000 / max) * max
59
+ const buffer = new Uint32Array(1)
60
+ do {
61
+ crypto.getRandomValues(buffer)
62
+ } while (buffer[0] >= limit)
63
+ return buffer[0] % max
26
64
  }
27
- }
65
+ }
@@ -14,7 +14,11 @@ module LatoUsers
14
14
  def authenticate_lato_users_admin
15
15
  return true if @session.user&.lato_users_admin
16
16
 
17
- redirect_to lato.root_path, alert: 'You have not access to this section.'
17
+ message = I18n.t('lato_users.not_authorized')
18
+ respond_to do |format|
19
+ format.html { redirect_to lato.root_path, alert: message }
20
+ format.any { render plain: message, status: :forbidden }
21
+ end
18
22
  end
19
23
  end
20
- end
24
+ end
@@ -15,19 +15,38 @@ module LatoUsers
15
15
  @invitation = Lato::Invitation.new
16
16
  end
17
17
 
18
+ # The invitation is persisted before the mail is sent: when delivery fails
19
+ # the admin is told so and can retry with the resend action.
18
20
  def create
19
21
  @invitation = Lato::Invitation.new(invitation_params.merge(inviter_lato_user_id: @session.user_id))
20
- if @invitation.save
22
+ if !save_invitation
23
+ render 'new', status: :unprocessable_entity
24
+ elsif @invitation.errors.any?
25
+ redirect_to invitations_path, alert: delivery_failure_message(@invitation)
26
+ else
21
27
  redirect_to invitations_path, notice: I18n.t('lato_users.invitation_created')
28
+ end
29
+ end
30
+
31
+ def resend
32
+ @invitation = Lato::Invitation.find(params[:id])
33
+ if @invitation.send_invite
34
+ redirect_to invitations_path, notice: I18n.t('lato_users.invitation_resent')
22
35
  else
23
- render 'new'
36
+ redirect_to invitations_path, alert: delivery_failure_message(@invitation)
24
37
  end
38
+ rescue StandardError => e
39
+ Rails.logger.error(e)
40
+ redirect_to invitations_path, alert: I18n.t('lato_users.invitation_email_failed')
25
41
  end
26
42
 
27
43
  def destroy
28
44
  @invitation = Lato::Invitation.find(params[:id])
29
- @invitation.destroy
30
- redirect_to invitations_path, notice: I18n.t('lato_users.invitation_destroyed')
45
+ if @invitation.destroy
46
+ redirect_to invitations_path, notice: I18n.t('lato_users.invitation_destroyed')
47
+ else
48
+ redirect_to invitations_path, alert: I18n.t('lato_users.cannot_delete_accepted_invitation')
49
+ end
31
50
  end
32
51
 
33
52
  private
@@ -35,5 +54,19 @@ module LatoUsers
35
54
  def invitation_params
36
55
  params.require(:invitation).permit(:email)
37
56
  end
57
+
58
+ # Mail delivery raising inside the after_create hook rolls the record back.
59
+ def save_invitation
60
+ @invitation.save
61
+ rescue StandardError => e
62
+ Rails.logger.error(e)
63
+ @invitation.errors.add(:base, I18n.t('lato_users.invitation_email_failed'))
64
+ false
65
+ end
66
+
67
+ def delivery_failure_message(invitation)
68
+ messages = invitation.errors.full_messages.join(', ')
69
+ [I18n.t('lato_users.invitation_email_failed'), messages.presence].compact.join(': ')
70
+ end
38
71
  end
39
- end
72
+ end
@@ -21,15 +21,17 @@ module LatoUsers
21
21
  @user = Lato::User.new
22
22
  end
23
23
 
24
+ # Lato::User validates the presence of the accepted privacy/terms versions, so
25
+ # admin-created users must carry the current versions to be saved at all.
24
26
  def create
25
- @user = Lato::User.new(user_params.merge(
27
+ @user = Lato::User.new(create_user_params.merge(
26
28
  accepted_privacy_policy_version: Lato.config.legal_privacy_policy_version,
27
29
  accepted_terms_and_conditions_version: Lato.config.legal_terms_and_conditions_version
28
30
  ))
29
- if @user.save
30
- redirect_to users_path
31
+ if permissions_valid?(@user) && @user.save
32
+ redirect_to users_path, notice: I18n.t('lato_users.user_created')
31
33
  else
32
- render 'new'
34
+ render 'new', status: :unprocessable_entity
33
35
  end
34
36
  end
35
37
 
@@ -39,29 +41,33 @@ module LatoUsers
39
41
 
40
42
  def update
41
43
  @user = Lato::User.find(params[:id])
42
- if @user.update(user_params)
43
- redirect_to(params[:redirect_to] || users_path)
44
+ @user.assign_attributes(update_user_params)
45
+ if permissions_valid?(@user) && @user.save
46
+ revoke_other_sessions(@user) if @user.saved_change_to_email?
47
+ redirect_to(url_from(params[:redirect_to]) || users_path, notice: I18n.t('lato_users.user_updated'))
44
48
  else
45
- render 'edit'
49
+ render 'edit', status: :unprocessable_entity
46
50
  end
47
51
  end
48
52
 
49
53
  def destroy
50
- if params[:id]&.to_i == @session.user_id
54
+ @user = Lato::User.find(params[:id])
55
+
56
+ if @user.id == @session.user_id
51
57
  redirect_to users_path, alert: I18n.t('lato_users.cannot_delete_self')
52
- return
58
+ elsif last_admin?(@user)
59
+ redirect_to users_path, alert: I18n.t('lato_users.cannot_delete_last_admin')
60
+ else
61
+ @user.destroy
62
+ redirect_to users_path, notice: I18n.t('lato_users.user_destroyed')
53
63
  end
54
-
55
- @user = Lato::User.find(params[:id])
56
- @user.destroy
57
- redirect_to users_path
58
64
  rescue ActiveRecord::InvalidForeignKey
59
65
  redirect_to users_path, alert: I18n.t('lato_users.cannot_delete_foreign_key')
60
66
  end
61
67
 
62
68
  def resend_verification_email
63
69
  @user = Lato::User.find(params[:id])
64
- if @user.request_verify_email
70
+ if deliver_verification_email(@user)
65
71
  redirect_to user_path(@user), notice: I18n.t('lato_users.verification_email_sent')
66
72
  else
67
73
  redirect_to user_path(@user), alert: @user.errors.full_messages.join(', ')
@@ -86,11 +92,15 @@ module LatoUsers
86
92
  end
87
93
  end
88
94
 
95
+ # The new password is rendered once in this response (no redirect), so it never
96
+ # reaches the flash/session cookie. Saving it revokes all the user sessions.
89
97
  def force_update_password
90
98
  @user = Lato::User.find(params[:id])
91
99
  new_password = SecureRandom.hex(8)
92
100
  if @user.update(password: new_password, password_confirmation: new_password)
93
- redirect_to user_path(@user), notice: I18n.t('lato_users.password_updated', password: new_password)
101
+ @generated_password = new_password
102
+ response.headers["Cache-Control"] = "no-store"
103
+ render 'show'
94
104
  else
95
105
  redirect_to user_path(@user), alert: I18n.t('lato_users.password_update_failed')
96
106
  end
@@ -98,11 +108,20 @@ module LatoUsers
98
108
 
99
109
  private
100
110
 
101
- def user_params
111
+ def base_user_params
102
112
  permission_keys = @available_admin_permissions.map { |permission| permission[:name] }
103
113
  params.require(:user).permit(:email, :first_name, :last_name, :password, :password_confirmation, *permission_keys)
104
114
  end
105
115
 
116
+ # Passwords can only be set on create: changing one afterwards goes through force_update_password.
117
+ def create_user_params
118
+ base_user_params
119
+ end
120
+
121
+ def update_user_params
122
+ base_user_params.except(:password, :password_confirmation)
123
+ end
124
+
106
125
  # Discover admin permissions on Lato::User by column naming convention.
107
126
  # Each engine (lato_cms, lato_spaces, ...) adds its own column:
108
127
  # - `lato_*_admin` -> boolean, rendered as a checkbox
@@ -123,5 +142,50 @@ module LatoUsers
123
142
  options_method = "#{name}_options"
124
143
  Lato::User.respond_to?(options_method) ? Lato::User.public_send(options_method) : []
125
144
  end
145
+
146
+ # Checks the assigned permission attributes and adds an error for each violation.
147
+ def permissions_valid?(user)
148
+ validate_role_values(user)
149
+ validate_users_admin_flag(user)
150
+ user.errors.empty?
151
+ end
152
+
153
+ def validate_role_values(user)
154
+ @available_admin_permissions.select { |permission| permission[:type] == :enum }.each do |permission|
155
+ name = permission[:name]
156
+ next unless user.will_save_change_to_attribute?(name)
157
+
158
+ allowed = permission[:options].map { |option| option.last.to_s }
159
+ user.errors.add(name, I18n.t('lato_users.invalid_permission_value')) unless allowed.include?(user[name].to_s)
160
+ end
161
+ end
162
+
163
+ def validate_users_admin_flag(user)
164
+ return unless user.persisted? && user.lato_users_admin_was && !user.lato_users_admin
165
+
166
+ if user.id == @session.user_id
167
+ user.errors.add(:lato_users_admin, I18n.t('lato_users.cannot_remove_own_admin'))
168
+ elsif last_admin?(user)
169
+ user.errors.add(:lato_users_admin, I18n.t('lato_users.cannot_remove_last_admin'))
170
+ end
171
+ end
172
+
173
+ def last_admin?(user)
174
+ user.lato_users_admin_in_database && !Lato::User.where(lato_users_admin: true).where.not(id: user.id).exists?
175
+ end
176
+
177
+ # Lato revokes sessions on password change only. A changed email must also cut off
178
+ # whoever holds a session on the old address. The admin's own sessions are kept.
179
+ def revoke_other_sessions(user)
180
+ user.lato_session_records.delete_all unless user.id == @session.user_id
181
+ end
182
+
183
+ def deliver_verification_email(user)
184
+ user.request_verify_email
185
+ rescue StandardError => e
186
+ Rails.logger.error(e)
187
+ user.errors.add(:base, I18n.t('lato_users.verification_email_failed'))
188
+ false
189
+ end
126
190
  end
127
- end
191
+ end
@@ -11,15 +11,19 @@ module LatoUsers
11
11
  ' - '
12
12
  end
13
13
  end
14
-
14
+
15
15
  def lato_invitation_actions(invitation)
16
16
  content_tag(:div, class: 'btn-group btn-group-sm') do
17
17
  if invitation.accepted_at.nil?
18
- concat link_to(I18n.t('lato_users.cta_delete'), lato_users.invitation_path(invitation), class: 'btn btn-danger', data: { turbo_confirm: I18n.t('lato_users.cta_delete_confirm'), turbo_method: :delete, turbo_frame: '_top' })
18
+ concat button_to(I18n.t('lato_users.cta_resend'), lato_users.resend_invitation_path(invitation), method: :post, class: 'btn btn-primary', form_class: 'd-inline-flex', aria: { label: I18n.t('lato_users.cta_resend_invitation', name: invitation.email) }, form: { data: { turbo_frame: '_top' } })
19
+ concat link_to(I18n.t('lato_users.cta_delete'), lato_users.invitation_path(invitation), class: 'btn btn-danger', aria: { label: I18n.t('lato_users.cta_delete_invitation', name: invitation.email) }, data: { turbo_confirm: I18n.t('lato_users.cta_delete_invitation_confirm', name: invitation.email), turbo_method: :delete, turbo_frame: '_top' })
19
20
  else
20
- concat content_tag(:button, I18n.t('lato_users.cta_delete'), class: 'btn btn-danger', disabled: true, title: I18n.t('lato_users.cannot_delete_accepted_invitation'))
21
+ hint_id = "invitation_#{invitation.id}_delete_hint"
22
+ reason = I18n.t('lato_users.cannot_delete_accepted_invitation')
23
+ concat content_tag(:button, I18n.t('lato_users.cta_delete'), type: 'button', class: 'btn btn-danger disabled', aria: { disabled: true, label: I18n.t('lato_users.cta_delete_invitation', name: invitation.email), describedby: hint_id }, title: reason)
24
+ concat content_tag(:span, reason, id: hint_id, class: 'visually-hidden')
21
25
  end
22
26
  end
23
27
  end
24
28
  end
25
- end
29
+ end
@@ -2,14 +2,36 @@ module LatoUsers
2
2
  module UsersHelper
3
3
  def lato_user_actions(user, show: true)
4
4
  content_tag(:div, class: 'btn-group btn-group-sm') do
5
- concat link_to(I18n.t('lato_users.cta_show'), lato_users.user_path(user), class: 'btn btn-secondary', data: { turbo_frame: '_top' }) if show
6
- concat link_to(I18n.t('lato_users.cta_edit'), lato_users.edit_user_path(user, redirect_to: request.fullpath), class: 'btn btn-primary', data: { lato_action_target: 'trigger', turbo_frame: dom_id(user, 'form'), action_title: I18n.t('lato_users.edit_user') })
5
+ concat link_to(I18n.t('lato_users.cta_show'), lato_users.user_path(user), class: 'btn btn-secondary', aria: { label: I18n.t('lato_users.cta_show_user', name: user.email) }, data: { turbo_frame: '_top' }) if show
6
+ concat link_to(I18n.t('lato_users.cta_edit'), lato_users.edit_user_path(user, redirect_to: request.fullpath), class: 'btn btn-primary', aria: { label: I18n.t('lato_users.cta_edit_user', name: user.email) }, data: { lato_action_target: 'trigger', turbo_frame: dom_id(user, 'form'), action_title: I18n.t('lato_users.edit_user') })
7
7
  if user.id == @session.user_id
8
- concat content_tag(:button, I18n.t('lato_users.cta_delete'), class: 'btn btn-danger', disabled: true, title: I18n.t('lato_users.cannot_delete_self'))
8
+ concat lato_disabled_delete_button(user, dom_id(user, 'delete_hint'), I18n.t('lato_users.cannot_delete_self'))
9
9
  else
10
- concat link_to(I18n.t('lato_users.cta_delete'), lato_users.user_path(user), class: 'btn btn-danger', data: { turbo_confirm: I18n.t('lato_users.cta_delete_confirm'), turbo_method: :delete, turbo_frame: '_top' })
10
+ concat link_to(I18n.t('lato_users.cta_delete'), lato_users.user_path(user), class: 'btn btn-danger', aria: { label: I18n.t('lato_users.cta_delete_user', name: user.email) }, data: { turbo_confirm: I18n.t('lato_users.cta_delete_confirm', name: user.email), turbo_method: :delete, turbo_frame: '_top' })
11
11
  end
12
12
  end
13
13
  end
14
+
15
+ # Same markup as lato_form_item_input_check, but the label points to the checkbox id.
16
+ # lato's helper builds `for="<column>"` while Rails generates `user_<column>`, so the
17
+ # label would not be associated with the input.
18
+ def lato_user_permission_check(form, user, name, label)
19
+ check_id = "#{dom_id(user, 'permission')}_#{name}"
20
+ options = { id: check_id }
21
+ _lato_form_input_options(form, name, options, :change, 'form-check-input')
22
+
23
+ content_tag(:div, class: 'form-check') do
24
+ concat form.check_box(name, options)
25
+ concat form.label(name, label, for: check_id, class: 'form-check-label')
26
+ end
27
+ end
28
+
29
+ private
30
+
31
+ # aria-disabled (not `disabled`) keeps the button focusable so the reason is reachable by keyboard and screen readers.
32
+ def lato_disabled_delete_button(user, hint_id, reason)
33
+ button = content_tag(:button, I18n.t('lato_users.cta_delete'), type: 'button', class: 'btn btn-danger disabled', aria: { disabled: true, label: I18n.t('lato_users.cta_delete_user', name: user.email), describedby: hint_id }, title: reason)
34
+ button + content_tag(:span, reason, id: hint_id, class: 'visually-hidden')
35
+ end
14
36
  end
15
- end
37
+ end
@@ -7,22 +7,22 @@
7
7
  <div class="row">
8
8
  <div class="col col-12 col-md-6 col-lg-3 mb-3">
9
9
  <label class="form-label" for="first_name"><%= I18n.t('activerecord.attributes.lato/user.first_name') %></label>
10
- <input type="text" id="first_name" class="form-control" value="<%= @user.first_name %>" disabled>
10
+ <input type="text" id="first_name" class="form-control" value="<%= @user.first_name %>" readonly>
11
11
  </div>
12
12
 
13
13
  <div class="col col-12 col-md-6 col-lg-3 mb-3">
14
14
  <label class="form-label" for="last_name"><%= I18n.t('activerecord.attributes.lato/user.last_name') %></label>
15
- <input type="text" id="last_name" class="form-control" value="<%= @user.last_name %>" disabled>
15
+ <input type="text" id="last_name" class="form-control" value="<%= @user.last_name %>" readonly>
16
16
  </div>
17
17
 
18
18
  <div class="col col-12 col-md-6 col-lg-3 mb-3">
19
19
  <label class="form-label" for="email"><%= I18n.t('activerecord.attributes.lato/user.email') %></label>
20
- <input type="text" id="email" class="form-control" value="<%= @user.email %>" disabled>
20
+ <input type="text" id="email" class="form-control" value="<%= @user.email %>" readonly>
21
21
  </div>
22
22
 
23
23
  <div class="col col-12 col-md-6 col-lg-3 mb-3">
24
24
  <label class="form-label" for="locale"><%= I18n.t('activerecord.attributes.lato/user.locale') %></label>
25
- <input type="text" id="locale" class="form-control" value="<%= @user.locale %>" disabled>
25
+ <input type="text" id="locale" class="form-control" value="<%= @user.locale %>" readonly>
26
26
  </div>
27
27
  </div>
28
28
  </div>
@@ -7,10 +7,10 @@
7
7
  <div class="d-flex flex-column flex-md-row align-items-md-center justify-content-between p-3 bg-success bg-opacity-10 border border-success rounded">
8
8
  <div class="d-flex align-items-center mb-3 mb-md-0">
9
9
  <div class="me-3 text-success">
10
- <i class="bi bi-check-circle-fill fs-4"></i>
10
+ <i class="bi bi-check-circle-fill fs-4" aria-hidden="true"></i>
11
11
  </div>
12
12
  <div>
13
- <h5 class="fs-6 fw-bold text-success mb-0"><%= I18n.t('lato_users.email_verified') %></h5>
13
+ <h3 class="fs-6 fw-bold text-success mb-0"><%= I18n.t('lato_users.email_verified') %></h3>
14
14
  <small class="text-muted"><%= I18n.t('lato_users.email_verified_at', date: l(@user.email_verified_at, format: :long)) %></small>
15
15
  </div>
16
16
  </div>
@@ -20,10 +20,10 @@
20
20
  <div class="d-flex flex-column flex-md-row align-items-md-center justify-content-between p-3 bg-danger bg-opacity-10 border border-danger rounded">
21
21
  <div class="d-flex align-items-center mb-3 mb-md-0">
22
22
  <div class="me-3 text-danger">
23
- <i class="bi bi-exclamation-triangle-fill fs-4"></i>
23
+ <i class="bi bi-exclamation-triangle-fill fs-4" aria-hidden="true"></i>
24
24
  </div>
25
25
  <div>
26
- <h5 class="fs-6 fw-bold text-danger mb-0"><%= I18n.t('lato_users.email_not_verified') %></h5>
26
+ <h3 class="fs-6 fw-bold text-danger mb-0"><%= I18n.t('lato_users.email_not_verified') %></h3>
27
27
  <small class="text-muted"><%= I18n.t('lato_users.email_verification_required') %></small>
28
28
  </div>
29
29
  </div>
@@ -5,7 +5,7 @@
5
5
  <div class="card-body">
6
6
  <div class="row">
7
7
  <div class="col col-12 col-lg-6 mb-3 mb-lg-0">
8
- <h5 class="fs-6 fw-bold mb-3"><%= I18n.t('lato_users.privacy_policy') %></h5>
8
+ <h3 class="fs-6 fw-bold mb-3"><%= I18n.t('lato_users.privacy_policy') %></h3>
9
9
  <p class="mb-1">
10
10
  <%= I18n.t('lato_users.accepted_version') %>:
11
11
  <span class="fw-bold"><%= @user.accepted_privacy_policy_version %></span>
@@ -17,26 +17,26 @@
17
17
  <% if @user.accepted_privacy_policy_version < Lato.config.legal_privacy_policy_version %>
18
18
  <div class="d-flex align-items-center p-3 bg-danger bg-opacity-10 border border-danger rounded">
19
19
  <div class="me-3 text-danger">
20
- <i class="bi bi-exclamation-triangle-fill fs-4"></i>
20
+ <i class="bi bi-exclamation-triangle-fill fs-4" aria-hidden="true"></i>
21
21
  </div>
22
22
  <div>
23
- <h5 class="fs-6 fw-bold text-danger mb-0"><%= I18n.t('lato_users.version_outdated') %></h5>
23
+ <h3 class="fs-6 fw-bold text-danger mb-0"><%= I18n.t('lato_users.version_outdated') %></h3>
24
24
  </div>
25
25
  </div>
26
26
  <% else %>
27
27
  <div class="d-flex align-items-center p-3 bg-success bg-opacity-10 border border-success rounded">
28
28
  <div class="me-3 text-success">
29
- <i class="bi bi-check-circle-fill fs-4"></i>
29
+ <i class="bi bi-check-circle-fill fs-4" aria-hidden="true"></i>
30
30
  </div>
31
31
  <div>
32
- <h5 class="fs-6 fw-bold text-success mb-0"><%= I18n.t('lato_users.version_up_to_date') %></h5>
32
+ <h3 class="fs-6 fw-bold text-success mb-0"><%= I18n.t('lato_users.version_up_to_date') %></h3>
33
33
  </div>
34
34
  </div>
35
35
  <% end %>
36
36
  </div>
37
37
 
38
38
  <div class="col col-12 col-lg-6">
39
- <h5 class="fs-6 fw-bold mb-3"><%= I18n.t('lato_users.terms_and_conditions') %></h5>
39
+ <h3 class="fs-6 fw-bold mb-3"><%= I18n.t('lato_users.terms_and_conditions') %></h3>
40
40
  <p class="mb-1">
41
41
  <%= I18n.t('lato_users.accepted_version') %>:
42
42
  <span class="fw-bold"><%= @user.accepted_terms_and_conditions_version %></span>
@@ -48,19 +48,19 @@
48
48
  <% if @user.accepted_terms_and_conditions_version < Lato.config.legal_terms_and_conditions_version %>
49
49
  <div class="d-flex align-items-center p-3 bg-danger bg-opacity-10 border border-danger rounded">
50
50
  <div class="me-3 text-danger">
51
- <i class="bi bi-exclamation-triangle-fill fs-4"></i>
51
+ <i class="bi bi-exclamation-triangle-fill fs-4" aria-hidden="true"></i>
52
52
  </div>
53
53
  <div>
54
- <h5 class="fs-6 fw-bold text-danger mb-0"><%= I18n.t('lato_users.version_outdated') %></h5>
54
+ <h3 class="fs-6 fw-bold text-danger mb-0"><%= I18n.t('lato_users.version_outdated') %></h3>
55
55
  </div>
56
56
  </div>
57
57
  <% else %>
58
58
  <div class="d-flex align-items-center p-3 bg-success bg-opacity-10 border border-success rounded">
59
59
  <div class="me-3 text-success">
60
- <i class="bi bi-check-circle-fill fs-4"></i>
60
+ <i class="bi bi-check-circle-fill fs-4" aria-hidden="true"></i>
61
61
  </div>
62
62
  <div>
63
- <h5 class="fs-6 fw-bold text-success mb-0"><%= I18n.t('lato_users.version_up_to_date') %></h5>
63
+ <h3 class="fs-6 fw-bold text-success mb-0"><%= I18n.t('lato_users.version_up_to_date') %></h3>
64
64
  </div>
65
65
  </div>
66
66
  <% end %>
@@ -45,19 +45,19 @@
45
45
 
46
46
  <div class="row mb-4">
47
47
  <div class="col-12">
48
- <h5 class="fs-6 fw-bold mb-3"><%= I18n.t('lato_users.signup_logs') %></h5>
48
+ <h3 class="fs-6 fw-bold mb-3"><%= I18n.t('lato_users.signup_logs') %></h3>
49
49
  <% if @user.lato_log_user_signups.any? %>
50
50
  <div class="list-group">
51
51
  <% @user.lato_log_user_signups.order(created_at: :desc).limit(5).each do |log| %>
52
52
  <div class="list-group-item p-3">
53
53
  <div class="row align-items-center gy-2">
54
54
  <div class="col-12 col-md-3 text-muted small">
55
- <i class="bi bi-calendar-event me-2"></i>
55
+ <i class="bi bi-calendar-event me-2" aria-hidden="true"></i>
56
56
  <%= l(log.created_at, format: :long) %>
57
57
  </div>
58
58
  <div class="col-12 col-md-3">
59
59
  <div class="d-flex align-items-center">
60
- <i class="bi bi-globe me-2 text-muted d-md-none"></i>
60
+ <i class="bi bi-globe me-2 text-muted d-md-none" aria-hidden="true"></i>
61
61
  <span class="text-truncate d-block" style="max-width: 100%;" title="<%= log.ip_address %>" data-bs-toggle="tooltip">
62
62
  <%= log.ip_address %>
63
63
  </span>
@@ -65,7 +65,7 @@
65
65
  </div>
66
66
  <div class="col-12 col-md-6 text-muted small">
67
67
  <div class="d-flex align-items-center">
68
- <i class="bi bi-laptop me-2 d-md-none"></i>
68
+ <i class="bi bi-laptop me-2 d-md-none" aria-hidden="true"></i>
69
69
  <span class="text-truncate d-block" style="max-width: 100%;" title="<%= log.user_agent %>" data-bs-toggle="tooltip">
70
70
  <%= log.user_agent %>
71
71
  </span>
@@ -77,7 +77,7 @@
77
77
  </div>
78
78
  <% else %>
79
79
  <div class="alert border text-center text-muted">
80
- <i class="bi bi-info-circle me-2"></i><%= I18n.t('lato_users.no_logs_found') %>
80
+ <i class="bi bi-info-circle me-2" aria-hidden="true"></i><%= I18n.t('lato_users.no_logs_found') %>
81
81
  </div>
82
82
  <% end %>
83
83
  </div>
@@ -85,19 +85,19 @@
85
85
 
86
86
  <div class="row mb-4">
87
87
  <div class="col-12">
88
- <h5 class="fs-6 fw-bold mb-3"><%= I18n.t('lato_users.login_logs') %></h5>
88
+ <h3 class="fs-6 fw-bold mb-3"><%= I18n.t('lato_users.login_logs') %></h3>
89
89
  <% if @user.lato_log_user_signins.any? %>
90
90
  <div class="list-group">
91
91
  <% @user.lato_log_user_signins.order(created_at: :desc).limit(5).each do |log| %>
92
92
  <div class="list-group-item p-3">
93
93
  <div class="row align-items-center gy-2">
94
94
  <div class="col-12 col-md-3 text-muted small">
95
- <i class="bi bi-calendar-event me-2"></i>
95
+ <i class="bi bi-calendar-event me-2" aria-hidden="true"></i>
96
96
  <%= l(log.created_at, format: :long) %>
97
97
  </div>
98
98
  <div class="col-12 col-md-3">
99
99
  <div class="d-flex align-items-center">
100
- <i class="bi bi-globe me-2 text-muted d-md-none"></i>
100
+ <i class="bi bi-globe me-2 text-muted d-md-none" aria-hidden="true"></i>
101
101
  <span class="text-truncate d-block" style="max-width: 100%;" title="<%= log.ip_address %>" data-bs-toggle="tooltip">
102
102
  <%= log.ip_address %>
103
103
  </span>
@@ -105,7 +105,7 @@
105
105
  </div>
106
106
  <div class="col-12 col-md-6 text-muted small">
107
107
  <div class="d-flex align-items-center">
108
- <i class="bi bi-laptop me-2 d-md-none"></i>
108
+ <i class="bi bi-laptop me-2 d-md-none" aria-hidden="true"></i>
109
109
  <span class="text-truncate d-block" style="max-width: 100%;" title="<%= log.user_agent %>" data-bs-toggle="tooltip">
110
110
  <%= log.user_agent %>
111
111
  </span>
@@ -117,7 +117,7 @@
117
117
  </div>
118
118
  <% else %>
119
119
  <div class="alert border text-center text-muted">
120
- <i class="bi bi-info-circle me-2"></i><%= I18n.t('lato_users.no_logs_found') %>
120
+ <i class="bi bi-info-circle me-2" aria-hidden="true"></i><%= I18n.t('lato_users.no_logs_found') %>
121
121
  </div>
122
122
  <% end %>
123
123
  </div>
@@ -125,20 +125,20 @@
125
125
 
126
126
  <div class="row">
127
127
  <div class="col-12">
128
- <h5 class="fs-6 fw-bold mb-3"><%= I18n.t('lato_users.password_management') %></h5>
128
+ <h3 class="fs-6 fw-bold mb-3"><%= I18n.t('lato_users.password_management') %></h3>
129
129
 
130
130
  <% if @user.password_digest.present? %>
131
131
  <div class="d-flex flex-column flex-md-row align-items-md-center justify-content-between p-3 bg-success bg-opacity-10 border border-success rounded">
132
132
  <div class="d-flex align-items-center mb-3 mb-md-0">
133
133
  <div class="me-3 text-success">
134
- <i class="bi bi-shield-lock-fill fs-4"></i>
134
+ <i class="bi bi-shield-lock-fill fs-4" aria-hidden="true"></i>
135
135
  </div>
136
136
  <div>
137
- <h5 class="fs-6 fw-bold text-success mb-0"><%= I18n.t('lato_users.password_set') %></h5>
137
+ <h3 class="fs-6 fw-bold text-success mb-0"><%= I18n.t('lato_users.password_set') %></h3>
138
138
  </div>
139
139
  </div>
140
140
  <div class="d-flex gap-2">
141
- <%= button_to force_update_password_user_path(@user), method: :patch, class: "btn btn-danger btn-sm d-flex align-items-center", form: { data: { turbo_confirm: I18n.t('lato_users.are_you_sure') } } do %>
141
+ <%= button_to force_update_password_user_path(@user), method: :patch, class: "btn btn-danger btn-sm d-flex align-items-center", form: { data: { turbo: false, controller: 'lato-users-form', action: 'submit->lato-users-form#confirmSubmit', lato_users_form_confirm_message_value: I18n.t('lato_users.force_password_confirm', name: @user.email) } } do %>
142
142
  <%= I18n.t('lato_users.force_password_update') %>
143
143
  <% end %>
144
144
  </div>
@@ -147,14 +147,14 @@
147
147
  <div class="d-flex flex-column flex-md-row align-items-md-center justify-content-between p-3 bg-danger bg-opacity-10 border border-danger rounded">
148
148
  <div class="d-flex align-items-center mb-3 mb-md-0">
149
149
  <div class="me-3 text-danger">
150
- <i class="bi bi-shield-exclamation fs-4"></i>
150
+ <i class="bi bi-shield-exclamation fs-4" aria-hidden="true"></i>
151
151
  </div>
152
152
  <div>
153
- <h5 class="fs-6 fw-bold text-danger mb-0"><%= I18n.t('lato_users.password_not_set') %></h5>
153
+ <h3 class="fs-6 fw-bold text-danger mb-0"><%= I18n.t('lato_users.password_not_set') %></h3>
154
154
  </div>
155
155
  </div>
156
156
  <div class="d-flex gap-2">
157
- <%= button_to force_update_password_user_path(@user), method: :patch, class: "btn btn-danger btn-sm d-flex align-items-center", form: { data: { turbo_confirm: I18n.t('lato_users.are_you_sure') } } do %>
157
+ <%= button_to force_update_password_user_path(@user), method: :patch, class: "btn btn-danger btn-sm d-flex align-items-center", form: { data: { turbo: false, controller: 'lato-users-form', action: 'submit->lato-users-form#confirmSubmit', lato_users_form_confirm_message_value: I18n.t('lato_users.force_password_confirm', name: @user.email) } } do %>
158
158
  <%= I18n.t('lato_users.force_password_update') %>
159
159
  <% end %>
160
160
  </div>
@@ -5,7 +5,7 @@ user ||= Lato::User.new
5
5
  %>
6
6
 
7
7
  <%= turbo_frame_tag dom_id(user, 'form') do %>
8
- <%= form_with model: user, url: user.persisted? ? lato_users.user_path(user) : lato_users.users_path, data: { turbo_frame: '_self', controller: 'lato-form lato-users-form' } do |form| %>
8
+ <%= form_with model: user, url: user.persisted? ? lato_users.user_path(user) : lato_users.users_path, data: { turbo_frame: '_self', controller: 'lato-form lato-users-form', lato_users_form_generated_message_value: I18n.t('lato_users.password_generated') } do |form| %>
9
9
  <%= lato_form_notices class: %w[mb-3] %>
10
10
  <%= lato_form_errors user, class: %w[mb-3] %>
11
11
 
@@ -34,12 +34,12 @@ user ||= Lato::User.new
34
34
  <div class="row">
35
35
  <div class="col col-12 col-md-6 mb-3">
36
36
  <%= lato_form_item_label form, :password %>
37
- <%= lato_form_item_input_password form, :password, required: true, data: { lato_users_form_target: 'password' } %>
37
+ <%= lato_form_item_input_password form, :password, required: true, autocomplete: 'new-password', data: { lato_users_form_target: 'password' } %>
38
38
  </div>
39
39
 
40
40
  <div class="col col-12 col-md-6 mb-3">
41
41
  <%= lato_form_item_label form, :password_confirmation %>
42
- <%= lato_form_item_input_password form, :password_confirmation, required: true, data: { lato_users_form_target: 'passwordConfirmation' } %>
42
+ <%= lato_form_item_input_password form, :password_confirmation, required: true, autocomplete: 'new-password', data: { lato_users_form_target: 'passwordConfirmation' } %>
43
43
  </div>
44
44
  </div>
45
45
 
@@ -49,16 +49,17 @@ user ||= Lato::User.new
49
49
  <div class="card-body">
50
50
  <div class="row align-items-center">
51
51
  <div class="col-auto">
52
- <button class="btn btn-primary" data-action="click->lato-users-form#generatePassword">
53
- <i class="bi bi-shuffle me-2"></i>
52
+ <button type="button" class="btn btn-primary" data-action="click->lato-users-form#generatePassword">
53
+ <i class="bi bi-shuffle me-2" aria-hidden="true"></i>
54
54
  <%= I18n.t('lato_users.generate_password') %>
55
55
  </button>
56
56
  </div>
57
57
  <div class="col">
58
58
  <div class="input-group">
59
- <span class="input-group-text"><i class="bi bi-key"></i></span>
60
- <input type="text" class="form-control font-monospace" readonly data-lato-users-form-target="generatedPassword" placeholder="...">
59
+ <span class="input-group-text"><i class="bi bi-key" aria-hidden="true"></i></span>
60
+ <input type="text" class="form-control font-monospace" readonly aria-label="<%= I18n.t('lato_users.generated_password') %>" data-lato-users-form-target="generatedPassword" placeholder="...">
61
61
  </div>
62
+ <span class="visually-hidden" role="status" aria-live="polite" data-lato-users-form-target="status"></span>
62
63
  </div>
63
64
  </div>
64
65
  </div>
@@ -68,14 +69,14 @@ user ||= Lato::User.new
68
69
  <% end %>
69
70
 
70
71
  <% if @available_admin_permissions.any? %>
71
- <div class="accordion mb-3" id="permissionsAccordion">
72
+ <div class="accordion mb-3" id="<%= dom_id(user, 'permissions_accordion') %>">
72
73
  <div class="accordion-item">
73
- <h2 class="accordion-header" id="headingPermissions">
74
- <button class="accordion-button collapsed" type="button" data-bs-toggle="collapse" data-bs-target="#collapsePermissions" aria-expanded="false" aria-controls="collapsePermissions">
74
+ <h2 class="accordion-header" id="<%= dom_id(user, 'permissions_heading') %>">
75
+ <button class="accordion-button collapsed" type="button" data-bs-toggle="collapse" data-bs-target="#<%= dom_id(user, 'permissions_collapse') %>" aria-expanded="false" aria-controls="<%= dom_id(user, 'permissions_collapse') %>">
75
76
  <%= I18n.t('lato_users.permissions') %>
76
77
  </button>
77
78
  </h2>
78
- <div id="collapsePermissions" class="accordion-collapse collapse" aria-labelledby="headingPermissions" data-bs-parent="#permissionsAccordion">
79
+ <div id="<%= dom_id(user, 'permissions_collapse') %>" class="accordion-collapse collapse" aria-labelledby="<%= dom_id(user, 'permissions_heading') %>" data-bs-parent="#<%= dom_id(user, 'permissions_accordion') %>">
79
80
  <div class="accordion-body">
80
81
  <div class="row">
81
82
  <% @available_admin_permissions.each_with_index do |permission, index| %>
@@ -86,7 +87,7 @@ user ||= Lato::User.new
86
87
  <%= lato_form_item_label form, permission[:name].to_sym, label %>
87
88
  <%= lato_form_item_input_select form, permission[:name].to_sym, permission[:options] %>
88
89
  <% else %>
89
- <%= lato_form_item_input_check form, permission[:name].to_sym, label %>
90
+ <%= lato_user_permission_check form, user, permission[:name].to_sym, label %>
90
91
  <% end %>
91
92
  </div>
92
93
  <% end %>
@@ -3,10 +3,19 @@
3
3
  { label: I18n.t('lato_users.show_user') }
4
4
  ] %>
5
5
 
6
+ <% if @generated_password %>
7
+ <div class="alert alert-warning mb-4" role="status">
8
+ <p class="fw-bold mb-2"><%= I18n.t('lato_users.password_updated_for', name: @user.email) %></p>
9
+ <label class="form-label" for="generated_password"><%= I18n.t('lato_users.generated_password') %></label>
10
+ <input type="text" id="generated_password" class="form-control font-monospace mb-2" value="<%= @generated_password %>" readonly autocomplete="off">
11
+ <p class="mb-0 small"><%= I18n.t('lato_users.password_shown_once') %></p>
12
+ </div>
13
+ <% end %>
14
+
6
15
  <%= render 'card_account_informations' %>
7
16
 
8
17
  <%= render 'card_email_verification' %>
9
18
 
10
19
  <%= render 'card_security' %>
11
20
 
12
- <%= render 'card_privacy_and_terms' %>
21
+ <%= render 'card_privacy_and_terms' %>
@@ -1,18 +1,33 @@
1
1
  en:
2
2
  lato_users:
3
- users: Users
4
- add_user: Add User
5
- edit_user: Edit User
6
- show_user: User details
7
- cta_show: Show
8
- cta_edit: Edit
9
- cta_update: Update
10
- cta_delete: Delete
11
- cta_confirm: Confirm
12
- cta_delete_confirm: Are you sure you want to delete this user?
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.
15
- account_informations: Account Informations
3
+ users: "Users"
4
+ add_user: "Add User"
5
+ edit_user: "Edit User"
6
+ show_user: "User details"
7
+ cta_show: "Show"
8
+ cta_edit: "Edit"
9
+ cta_update: "Update"
10
+ cta_delete: "Delete"
11
+ cta_confirm: "Confirm"
12
+ cta_resend: "Resend"
13
+ cta_show_user: "Show %{name}"
14
+ cta_edit_user: "Edit %{name}"
15
+ cta_delete_user: "Delete %{name}"
16
+ cta_delete_confirm: "Are you sure you want to delete the user %{name}? This action cannot be undone."
17
+ cta_resend_invitation: "Resend invitation to %{name}"
18
+ cta_delete_invitation: "Delete invitation for %{name}"
19
+ cta_delete_invitation_confirm: "Are you sure you want to delete the invitation for %{name}?"
20
+ not_authorized: "You do not have access to this section."
21
+ user_created: "User created"
22
+ user_updated: "User updated"
23
+ user_destroyed: "User deleted"
24
+ cannot_delete_self: "You cannot delete your own user account."
25
+ cannot_delete_last_admin: "You cannot delete the last users admin."
26
+ cannot_remove_own_admin: "You cannot remove your own users admin permission."
27
+ cannot_remove_last_admin: "You cannot remove the permission from the last users admin."
28
+ invalid_permission_value: "is not an allowed value"
29
+ 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."
30
+ account_informations: "Account Information"
16
31
  email_verification: "Email Verification"
17
32
  email_verified: "Email Verified"
18
33
  email_verified_at: "Verified on %{date}"
@@ -23,6 +38,7 @@ en:
23
38
  resend_verification_email: "Resend verification email"
24
39
  manual_verify_email: "Manually verify"
25
40
  verification_email_sent: "Verification email sent"
41
+ verification_email_failed: "Unable to send the verification email"
26
42
  email_manually_verified: "Email manually verified"
27
43
  email_verification_revoked: "Email verification revoked"
28
44
  privacy_and_terms: "Privacy Policy and Terms"
@@ -34,29 +50,37 @@ en:
34
50
  version_up_to_date: "Version up to date"
35
51
  security: "Security"
36
52
  signup_logs: "Signup Logs"
37
- date: "Date"
38
- ip_address: "IP Address"
39
- user_agent: "User Agent"
40
53
  no_logs_found: "No logs found"
41
54
  login_logs: "Login Logs"
42
55
  password_management: "Password Management"
43
56
  password_set: "Password set"
44
57
  password_not_set: "Password not set"
45
- send_reset_password_email: "Send reset password email"
46
58
  force_password_update: "Force password update"
47
- recover_password_email_sent: "Recovery password email sent"
48
- recover_password_email_failed: "Failed to send recovery password email"
49
- password_updated: "Password updated: %{password}"
59
+ force_password_confirm: "Generate a new password for %{name}? All of their sessions will be revoked."
60
+ password_updated_for: "New password set for %{name}"
61
+ generated_password: "Generated password"
62
+ password_generated: "Password generated and filled in"
63
+ password_shown_once: "This password is shown only once and is not stored anywhere. Copy it now and share it securely: reloading the page will not show it again."
50
64
  password_update_failed: "Failed to update password"
51
65
  authenticator_connection: "Authenticator Connection"
52
66
  invitations: "Invitations"
53
67
  add_invitation: "Add Invitation"
54
68
  invitation_created: "Invitation created"
69
+ invitation_resent: "Invitation sent again"
70
+ invitation_email_failed: "The invitation email could not be sent"
55
71
  invitation_destroyed: "Invitation destroyed"
72
+ cannot_delete_accepted_invitation: "Accepted invitations cannot be deleted."
56
73
  webauthn_connection: "WebAuthn Connection"
57
74
  connected: "Connected"
58
75
  not_connected: "Not Connected"
59
76
  devices_count: "Connected Devices"
60
- invitations: "Invitations"
61
- generate_password: 'Generate Password'
77
+ generate_password: "Generate Password"
62
78
  permissions: "Permissions"
79
+ activerecord:
80
+ attributes:
81
+ lato/user:
82
+ lato_users_admin: "Users admin"
83
+ lato_settings_admin: "Settings admin"
84
+ lato_spaces_admin: "Spaces admin"
85
+ lato_storage_admin: "Storage admin"
86
+ lato_cms_admin_role: "CMS role"
@@ -1,18 +1,33 @@
1
1
  it:
2
2
  lato_users:
3
- users: Utenti
4
- add_user: Aggiungi Utente
5
- edit_user: Modifica Utente
6
- show_user: Dettagli Utente
7
- cta_show: Visualizza
8
- cta_edit: Modifica
9
- cta_update: Aggiorna
10
- cta_delete: Elimina
11
- cta_confirm: Conferma
12
- cta_delete_confirm: Sei sicuro di voler eliminare questo utente?
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.
15
- account_informations: Informazioni Account
3
+ users: "Utenti"
4
+ add_user: "Aggiungi Utente"
5
+ edit_user: "Modifica Utente"
6
+ show_user: "Dettagli Utente"
7
+ cta_show: "Visualizza"
8
+ cta_edit: "Modifica"
9
+ cta_update: "Aggiorna"
10
+ cta_delete: "Elimina"
11
+ cta_confirm: "Conferma"
12
+ cta_resend: "Reinvia"
13
+ cta_show_user: "Visualizza %{name}"
14
+ cta_edit_user: "Modifica %{name}"
15
+ cta_delete_user: "Elimina %{name}"
16
+ cta_delete_confirm: "Sei sicuro di voler eliminare l'utente %{name}? L'azione non può essere annullata."
17
+ cta_resend_invitation: "Reinvia invito a %{name}"
18
+ cta_delete_invitation: "Elimina invito per %{name}"
19
+ cta_delete_invitation_confirm: "Sei sicuro di voler eliminare l'invito per %{name}?"
20
+ not_authorized: "Non hai accesso a questa sezione."
21
+ user_created: "Utente creato"
22
+ user_updated: "Utente aggiornato"
23
+ user_destroyed: "Utente eliminato"
24
+ cannot_delete_self: "Non puoi eliminare il tuo account utente."
25
+ cannot_delete_last_admin: "Non puoi eliminare l'ultimo amministratore utenti."
26
+ cannot_remove_own_admin: "Non puoi rimuovere il tuo permesso di amministratore utenti."
27
+ cannot_remove_last_admin: "Non puoi rimuovere il permesso all'ultimo amministratore utenti."
28
+ invalid_permission_value: "non è un valore consentito"
29
+ 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."
30
+ account_informations: "Informazioni Account"
16
31
  email_verification: "Verifica Email"
17
32
  email_verified: "Email Verificata"
18
33
  email_verified_at: "Verificata il %{date}"
@@ -23,6 +38,7 @@ it:
23
38
  resend_verification_email: "Invia nuovamente email di verifica"
24
39
  manual_verify_email: "Verifica manualmente"
25
40
  verification_email_sent: "Email di verifica inviata"
41
+ verification_email_failed: "Impossibile inviare l'email di verifica"
26
42
  email_manually_verified: "Email verificata manualmente"
27
43
  email_verification_revoked: "Verifica email revocata"
28
44
  privacy_and_terms: "Privacy Policy e Termini"
@@ -34,28 +50,37 @@ it:
34
50
  version_up_to_date: "Versione aggiornata"
35
51
  security: "Sicurezza"
36
52
  signup_logs: "Log di Registrazione"
37
- date: "Data"
38
- ip_address: "Indirizzo IP"
39
- user_agent: "User Agent"
40
53
  no_logs_found: "Nessun log trovato"
41
54
  login_logs: "Log di Accesso"
42
55
  password_management: "Gestione Password"
43
56
  password_set: "Password impostata"
44
57
  password_not_set: "Password non impostata"
45
- send_reset_password_email: "Invia email di reset password"
46
58
  force_password_update: "Forza aggiornamento password"
47
- recover_password_email_sent: "Email di recupero password inviata"
48
- recover_password_email_failed: "Impossibile inviare email di recupero password"
49
- password_updated: "Password aggiornata: %{password}"
59
+ force_password_confirm: "Generare una nuova password per %{name}? Tutte le sue sessioni verranno revocate."
60
+ password_updated_for: "Nuova password impostata per %{name}"
61
+ generated_password: "Password generata"
62
+ password_generated: "Password generata e inserita nei campi"
63
+ password_shown_once: "Questa password viene mostrata una sola volta e non viene salvata. Copiala ora e condividila in modo sicuro: ricaricando la pagina non sarà più visibile."
50
64
  password_update_failed: "Impossibile aggiornare la password"
51
65
  authenticator_connection: "Connessione Authenticator"
52
66
  invitations: "Inviti"
53
67
  add_invitation: "Aggiungi Invito"
54
68
  invitation_created: "Invito creato"
69
+ invitation_resent: "Invito inviato nuovamente"
70
+ invitation_email_failed: "Impossibile inviare l'email di invito"
55
71
  invitation_destroyed: "Invito eliminato"
72
+ cannot_delete_accepted_invitation: "Gli inviti accettati non possono essere eliminati."
56
73
  webauthn_connection: "Connessione WebAuthn"
57
74
  connected: "Connesso"
58
75
  not_connected: "Non Connesso"
59
76
  devices_count: "Dispositivi Connessi"
60
- generate_password: 'Genera Password'
77
+ generate_password: "Genera Password"
61
78
  permissions: "Permessi"
79
+ activerecord:
80
+ attributes:
81
+ lato/user:
82
+ lato_users_admin: "Amministratore utenti"
83
+ lato_settings_admin: "Amministratore impostazioni"
84
+ lato_spaces_admin: "Amministratore spazi"
85
+ lato_storage_admin: "Amministratore storage"
86
+ lato_cms_admin_role: "Ruolo CMS"
data/config/routes.rb CHANGED
@@ -10,5 +10,9 @@ LatoUsers::Engine.routes.draw do
10
10
  end
11
11
  end
12
12
 
13
- resources :invitations, except: [:show, :edit, :update]
13
+ resources :invitations, except: [:show, :edit, :update] do
14
+ member do
15
+ post :resend
16
+ end
17
+ end
14
18
  end
@@ -1,3 +1,3 @@
1
1
  module LatoUsers
2
- VERSION = "3.0.6"
2
+ VERSION = "3.1.0"
3
3
  end
@@ -2,10 +2,10 @@ require 'fileutils'
2
2
 
3
3
  namespace :lato_users do
4
4
  namespace :install do
5
- desc 'Install Lato users engine and run tasks on main rails application'
5
+ desc 'No-op: Lato Users needs no application-level install step (kept for forward compatibility)'
6
6
  # Usage: rails lato_users:install:application
7
7
  task :application do
8
- # Free for future use...
8
+ # Intentionally empty: setup is gem + migrations + mount + imports.
9
9
  end
10
10
  end
11
11
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lato_users
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.6
4
+ version: 3.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gregorio Galante
@@ -15,28 +15,34 @@ dependencies:
15
15
  requirements:
16
16
  - - ">="
17
17
  - !ruby/object:Gem::Version
18
- version: 7.1.1
18
+ version: 8.1.3.1
19
+ - - "<"
20
+ - !ruby/object:Gem::Version
21
+ version: '8.2'
19
22
  type: :runtime
20
23
  prerelease: false
21
24
  version_requirements: !ruby/object:Gem::Requirement
22
25
  requirements:
23
26
  - - ">="
24
27
  - !ruby/object:Gem::Version
25
- version: 7.1.1
28
+ version: 8.1.3.1
29
+ - - "<"
30
+ - !ruby/object:Gem::Version
31
+ version: '8.2'
26
32
  - !ruby/object:Gem::Dependency
27
33
  name: lato
28
34
  requirement: !ruby/object:Gem::Requirement
29
35
  requirements:
30
36
  - - ">="
31
37
  - !ruby/object:Gem::Version
32
- version: '0'
38
+ version: 3.25.0
33
39
  type: :runtime
34
40
  prerelease: false
35
41
  version_requirements: !ruby/object:Gem::Requirement
36
42
  requirements:
37
43
  - - ">="
38
44
  - !ruby/object:Gem::Version
39
- version: '0'
45
+ version: 3.25.0
40
46
  description: A Rails engine to manage application users on Lato projects!
41
47
  email:
42
48
  - me@gregoriogalante.com