lesli_shield 1.1.9 → 1.1.10

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.
Files changed (39) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/images/lesli_shield/login-background.webp +0 -0
  3. data/app/assets/images/lesli_shield/register-background.webp +0 -0
  4. data/app/assets/stylesheets/lesli_shield/application.css +23 -28
  5. data/app/assets/stylesheets/lesli_shield/invitations.css +1 -1
  6. data/app/assets/stylesheets/lesli_shield/registrations.css +35 -10
  7. data/app/assets/stylesheets/lesli_shield/sessions.css +1 -1
  8. data/app/controllers/lesli_shield/profile/passwords_controller.rb +0 -2
  9. data/app/controllers/lesli_shield/profiles_controller.rb +0 -1
  10. data/app/controllers/lesli_shield/user/roles_controller.rb +35 -59
  11. data/app/controllers/lesli_shield/users_controller.rb +4 -2
  12. data/app/controllers/users/registrations_controller.rb +27 -0
  13. data/app/controllers/users/sessions_controller.rb +11 -0
  14. data/app/interfaces/lesli_shield/security_interface.rb +146 -0
  15. data/app/models/concerns/lesli_shield/user_authentication.rb +0 -29
  16. data/app/models/concerns/lesli_shield/user_legal_acceptance.rb +45 -0
  17. data/app/models/concerns/lesli_shield/user_security.rb +23 -14
  18. data/app/services/lesli_shield/user_role_service.rb +37 -0
  19. data/app/services/lesli_shield/user_validator_service.rb +6 -28
  20. data/app/views/devise/registrations/_terms.html.erb +34 -0
  21. data/app/views/devise/registrations/new.html.erb +3 -5
  22. data/app/views/devise/sessions/new.html.erb +2 -1
  23. data/app/views/lesli_shield/partials/_navigation.html.erb +5 -5
  24. data/app/views/lesli_shield/roles/show.html.erb +40 -50
  25. data/app/views/lesli_shield/user/roles/index.html.erb +1 -16
  26. data/app/views/lesli_shield/users/_management-privileges.html.erb +74 -68
  27. data/app/views/lesli_shield/users/show.html.erb +1 -1
  28. data/config/locales/translations.en.yml +8 -1
  29. data/config/locales/translations.es.yml +8 -1
  30. data/config/locales/user_roles.en.yml +16 -0
  31. data/config/locales/user_roles.es.yml +16 -0
  32. data/config/routes.rb +1 -1
  33. data/lib/lesli_shield/engine.rb +4 -0
  34. data/lib/lesli_shield/version.rb +1 -1
  35. metadata +10 -6
  36. data/app/assets/images/lesli_shield/login-background.jpg +0 -0
  37. data/app/assets/images/lesli_shield/register-background.jpg +0 -0
  38. data/app/interfaces/lesli_shield/authentication_interface.rb +0 -64
  39. data/app/interfaces/lesli_shield/authorization_interface.rb +0 -46
@@ -0,0 +1,45 @@
1
+ # frozen_string_literal: true
2
+
3
+ module LesliShield
4
+ module UserLegalAcceptance
5
+ extend ActiveSupport::Concern
6
+
7
+ included do
8
+ attr_accessor :terms_accepted, :legal_acceptance_required
9
+
10
+ # Only public signup sets this flag. Existing users, invitations and
11
+ # administrative creation must not receive invented acceptance records.
12
+ validate :validate_registration_terms, on: :create, if: :legal_acceptance_required
13
+ before_create :record_legal_acceptance, if: :legal_acceptance_required
14
+ end
15
+
16
+ # Shared by validation and the form: an outdated form needs a new review.
17
+ def current_registration_documents?
18
+ terms_version.present? && privacy_version.present? &&
19
+ terms_version == Lesli.config.shield[:terms_version] &&
20
+ privacy_version == Lesli.config.shield[:privacy_version]
21
+ end
22
+
23
+ private
24
+
25
+ def validate_registration_terms
26
+ unless ["1", true].include?(terms_accepted)
27
+ errors.add(:base, I18n.t(
28
+ "overrides.lesli_shield.devise_registrations.message_terms_required",
29
+ default: :"lesli_shield.devise_registrations.message_terms_required"
30
+ ))
31
+ end
32
+
33
+ unless current_registration_documents?
34
+ errors.add(:base, I18n.t("lesli_shield.devise_registrations.message_legal_documents_changed"))
35
+ end
36
+ end
37
+
38
+ def record_legal_acceptance
39
+ # Never accept a timestamp or accepted version supplied by the client.
40
+ self.terms_accepted_at = Time.current
41
+ self.terms_version = Lesli.config.shield.fetch(:terms_version)
42
+ self.privacy_version = Lesli.config.shield.fetch(:privacy_version)
43
+ end
44
+ end
45
+ end
@@ -47,22 +47,31 @@ module LesliShield
47
47
  !roles.intersection(self.roles.map{ |r| r[:name] }).empty?
48
48
  end
49
49
 
50
- # check the privilege cache to check if user is able
51
- # to perform a specific action in a specific controller
50
+ # Cache only while handling an HTTP request. Jobs and standalone model
51
+ # calls keep querying current privileges, and ensure clears state on errors.
52
+ def with_privileges
53
+ @request_privileges = nil
54
+ @request_privileges_enabled = true
55
+ yield
56
+ ensure
57
+ @request_privileges = nil
58
+ @request_privileges_enabled = false
59
+ end
60
+
52
61
  def has_privileges_for?(controller, action)
53
- begin
54
- active_role_ids = roles.where(active: true).select(:id)
55
-
56
- return Role::Privilege.where(
57
- role_id: active_role_ids,
58
- controller: controller,
59
- action: action,
60
- active: true
61
- ).exists?
62
- rescue => exception
63
- Termline.danger(exception.to_s)
64
- return false
62
+ privileges = Role::Privilege.where(
63
+ role_id: roles.where(active: true).select(:id), active: true
64
+ )
65
+
66
+ if @request_privileges_enabled
67
+ @request_privileges ||= privileges.distinct.pluck(:controller, :action).to_set
68
+ @request_privileges.include?([controller.to_s, action.to_s])
69
+ else
70
+ privileges.exists?(controller: controller, action: action)
65
71
  end
72
+ rescue StandardError => exception
73
+ Termline.danger(exception.to_s)
74
+ false
66
75
  end
67
76
 
68
77
  # A user can assign only active roles from their own account and never
@@ -0,0 +1,37 @@
1
+ module LesliShield
2
+ class UserRoleService
3
+ def initialize(current_user, user)
4
+ @current_user = current_user
5
+ @user = user
6
+ end
7
+
8
+ def index
9
+ @user.user_roles.includes(:role).order(:id)
10
+ end
11
+
12
+ def list
13
+ @current_user.account.roles.where(active: true)
14
+ .where(permission_level: ..@current_user.max_level_permission)
15
+ .where.not(id: @user.roles.select(:id)).order(:name, :id)
16
+ end
17
+
18
+ def create(role_id)
19
+ role = @current_user.account.roles.find(role_id)
20
+ raise ActiveRecord::RecordNotFound unless @current_user.can_assign_role?(role)
21
+
22
+ @user.user_roles.find_or_create_by!(role: role)
23
+ end
24
+
25
+ def destroy(id)
26
+ assignment = @user.user_roles.includes(:role).find(id)
27
+ # Inactive roles can still be removed within the administrator's level.
28
+ role = assignment.role
29
+ unless role.account_id == @current_user.account_id &&
30
+ role.permission_level.to_i <= @current_user.max_level_permission
31
+ raise ActiveRecord::RecordNotFound
32
+ end
33
+
34
+ assignment.destroy!
35
+ end
36
+ end
37
+ end
@@ -42,7 +42,12 @@ module LesliShield
42
42
  def validate
43
43
  account_present?()
44
44
  active?()
45
- active_roles?() unless roles_empty?()
45
+ role_states = current_user.roles.distinct.pluck(:active)
46
+ if role_states.empty?
47
+ log_failure("user_has_no_assigned_role")
48
+ elsif !role_states.include?(true)
49
+ log_failure("user_has_no_active_role")
50
+ end
46
51
  self
47
52
  end
48
53
 
@@ -183,33 +188,6 @@ module LesliShield
183
188
  return true
184
189
  end
185
190
 
186
- def roles_empty?
187
-
188
- # check if user has roles assigned
189
- unless current_user.roles.exists?
190
-
191
- log_failure("user_has_no_assigned_role")
192
-
193
- return true
194
-
195
- end
196
-
197
- return false
198
-
199
- end
200
-
201
- def active_roles?
202
-
203
- # check user has at least one active role before authorize the sign-in request
204
- unless current_user.roles.exists?(active: true)
205
- log_failure("user_has_no_active_role")
206
-
207
- return false
208
- end
209
-
210
- return true
211
- end
212
-
213
191
  def log_failure(description)
214
192
  errors.push(description) unless errors.include?(description)
215
193
  end
@@ -0,0 +1,34 @@
1
+ <%# locals: (form:) %>
2
+ <% legal = Lesli.config.shield %>
3
+
4
+ <%= form.hidden_field :terms_version, value: legal.fetch(:terms_version) %>
5
+ <%= form.hidden_field :privacy_version, value: legal.fetch(:privacy_version) %>
6
+
7
+ <div class="my-6 text-sm leading-relaxed text-neutral-600">
8
+ <div class="flex items-start gap-3">
9
+ <%= form.check_box :terms_accepted,
10
+ required: true,
11
+ class: "mt-1 size-4 shrink-0 accent-primary focus-visible:outline-2 focus-visible:outline-offset-4 focus-visible:outline-primary",
12
+ checked: (["1", true].include?(resource.terms_accepted) && resource.current_registration_documents?),
13
+ aria: { describedby: "registration-privacy-notice", invalid: resource.errors.any? } %>
14
+ <%= form.label :terms_accepted, class: "cursor-pointer" do %>
15
+ <%= t("overrides.lesli_shield.devise_registrations.label_terms_html",
16
+ default: :"lesli_shield.devise_registrations.label_terms_html",
17
+ terms: link_to(
18
+ t("lesli_shield.devise_registrations.link_terms"),
19
+ legal.fetch(:terms_url), target: "_blank", rel: "noopener",
20
+ class: "text-primary-strong underline underline-offset-2 focus-visible:outline-2 focus-visible:outline-offset-4 focus-visible:outline-primary",
21
+ aria: { label: t("lesli_shield.devise_registrations.link_terms_new_tab") }
22
+ )) %>
23
+ <% end %>
24
+ </div>
25
+ <p id="registration-privacy-notice" class="mt-3 text-xs leading-relaxed">
26
+ <%= t("lesli_shield.devise_registrations.view_privacy_notice_html",
27
+ privacy: link_to(
28
+ t("lesli_shield.devise_registrations.link_privacy"),
29
+ legal.fetch(:privacy_url), target: "_blank", rel: "noopener",
30
+ class: "text-primary-strong underline underline-offset-2 focus-visible:outline-2 focus-visible:outline-offset-4 focus-visible:outline-primary",
31
+ aria: { label: t("lesli_shield.devise_registrations.link_privacy_new_tab") }
32
+ )) %>
33
+ </p>
34
+ </div>
@@ -97,11 +97,9 @@ title = I18n.t("overrides.lesli_shield.devise_registrations.view_title",
97
97
  value: ""
98
98
  ) %>
99
99
 
100
- <div class="mb-4">
101
- <p class="text-left text-xs leading-5 text-neutral-500">
102
- <%= I18n.t("lesli_shield.devise_registrations.view_legal_notice") %>
103
- </p>
104
- </div>
100
+ <% if Lesli.config.shield[:require_terms_acceptance] %>
101
+ <%= render "devise/registrations/terms", form: form %>
102
+ <% end %>
105
103
 
106
104
  <%= form.field_control_button(
107
105
  I18n.t(
@@ -54,7 +54,8 @@ end
54
54
  autofocus: true,
55
55
  autocomplete: "email",
56
56
  required: true,
57
- placeholder: Lesli.config.company[:email]
57
+ placeholder: I18n.t("lesli_shield.devise_sessions.placeholder_email",
58
+ default: Lesli.config.company[:email])
58
59
  }
59
60
 
60
61
  password_field_options = {
@@ -30,8 +30,8 @@ Building a better future, one line of code at a time.
30
30
  // ·
31
31
  %>
32
32
 
33
- <%= navigation_item(lesli_shield.dashboard_path, "Dashboard", "ri-dashboard-3-line"); %>
34
- <%= navigation_item(lesli_shield.users_path, "Users", "ri-user-line"); %>
35
- <%= navigation_item(lesli_shield.sessions_path, "Sessions", "ri-lock-line") %>
36
- <%= navigation_item(lesli_shield.roles_path, "Roles", "ri-shield-user-line") %>
37
- <%= navigation_item(lesli_shield.invites_path, "Invites", "ri-user-add-line") %>
33
+ <%= navigation_item(lesli_shield.dashboard_path, "Dashboard", "ri-dashboard-3-line", access: ["lesli_shield/dashboards", :show]); %>
34
+ <%= navigation_item(lesli_shield.users_path, "Users", "ri-user-line", access: ["lesli_shield/users", :index]); %>
35
+ <%= navigation_item(lesli_shield.sessions_path, "Sessions", "ri-lock-line", access: ["lesli_shield/sessions", :index]) %>
36
+ <%= navigation_item(lesli_shield.roles_path, "Roles", "ri-shield-user-line", access: ["lesli_shield/roles", :index]) %>
37
+ <%= navigation_item(lesli_shield.invites_path, "Invites", "ri-user-add-line", access: ["lesli_shield/invites", :index]) %>
@@ -22,61 +22,51 @@ members_plural = members_count == 1 ? "one" : "other"
22
22
  icon: "content_copy", url: duplicate_role_path(@role), method: :post,
23
23
  data: { turbo_submits_with: t("lesli_shield.roles.action_duplicating") }
24
24
  ) %>
25
-
26
25
  <% end %>
27
26
 
28
- <%
29
- navigation_items = [{ label: t("lesli_shield.roles.detail_summary_title"), path: role_path(@role), selected: true }]
30
- unless @role.protected_role?
31
- navigation_items << { label: t("lesli_shield.roles.detail_manage_permissions"), path: role_actions_path(@role), selected: false }
32
- end
33
- %>
34
- <div class="flex min-w-0 flex-col gap-6 lg:flex-row lg:items-start">
35
- <%= render LesliView::Layout::NavigationSidebar.new(items: navigation_items, label: @role.name) %>
36
- <div id="role-detail-content" class="min-w-0 flex-1 space-y-6">
37
- <section id="members" class="rounded-2xl border border-neutral-200 bg-white p-5 shadow-sm sm:p-6" aria-labelledby="role-summary-title">
38
- <div class="flex items-center justify-between gap-3">
39
- <h2 id="role-summary-title" class="text-base font-semibold text-neutral-900">
40
- <%= t("lesli_shield.roles.detail_summary_title") %>
41
- </h2>
42
- <%= render "status_badge", role: @role %>
43
- </div>
44
-
45
- <dl class="mt-3 flex flex-wrap gap-8">
46
- <div>
47
- <dt class="text-xs font-medium uppercase tracking-wide text-neutral-500">
48
- <%= t("lesli_shield.roles.detail_members") %>
49
- </dt>
50
- <dd class="mt-1 text-2xl font-semibold text-neutral-900">
51
- <%= @role_summary.fetch(:members) %>
52
- </dd>
53
- </div>
54
- <div>
55
- <dt class="text-xs font-medium uppercase tracking-wide text-neutral-500">
56
- <%= t("lesli_shield.roles.detail_permissions") %>
57
- </dt>
58
- <dd class="mt-1 text-2xl font-semibold text-neutral-900">
59
- <%= @role_summary.fetch(:permissions) %>
60
- </dd>
61
- </div>
62
- </dl>
27
+ <div id="role-detail-content" class="min-w-0 w-full space-y-6">
28
+ <section id="members" class="rounded-2xl border border-neutral-200 bg-white p-5 shadow-sm sm:p-6" aria-labelledby="role-summary-title">
29
+ <div class="flex items-center justify-between gap-3">
30
+ <h2 id="role-summary-title" class="text-base font-semibold text-neutral-900">
31
+ <%= t("lesli_shield.roles.detail_summary_title") %>
32
+ </h2>
33
+ <%= render "status_badge", role: @role %>
34
+ </div>
63
35
 
64
- <div class="mt-5 border-t border-neutral-200 pt-5">
65
- <h3 id="role-status-title" class="text-sm font-semibold text-neutral-800">
66
- <%= t("lesli_shield.roles.detail_status_title") %>
67
- </h3>
68
- <p class="mt-2 text-sm leading-6 text-neutral-500">
69
- <%= @role.active? ?
70
- t("lesli_shield.roles.detail_active_impact_#{members_plural}", count: members_count) :
71
- t("lesli_shield.roles.detail_inactive_impact_#{members_plural}", count: members_count) %>
72
- </p>
36
+ <dl class="mt-3 flex flex-wrap gap-8">
37
+ <div>
38
+ <dt class="text-xs font-medium uppercase tracking-wide text-neutral-500">
39
+ <%= t("lesli_shield.roles.detail_members") %>
40
+ </dt>
41
+ <dd class="mt-1 text-2xl font-semibold text-neutral-900">
42
+ <%= @role_summary.fetch(:members) %>
43
+ </dd>
73
44
  </div>
74
- </section>
45
+ <div>
46
+ <dt class="text-xs font-medium uppercase tracking-wide text-neutral-500">
47
+ <%= t("lesli_shield.roles.detail_permissions") %>
48
+ </dt>
49
+ <dd class="mt-1 text-2xl font-semibold text-neutral-900">
50
+ <%= @role_summary.fetch(:permissions) %>
51
+ </dd>
52
+ </div>
53
+ </dl>
54
+
55
+ <div class="mt-5 border-t border-neutral-200 pt-5">
56
+ <h3 id="role-status-title" class="text-sm font-semibold text-neutral-800">
57
+ <%= t("lesli_shield.roles.detail_status_title") %>
58
+ </h3>
59
+ <p class="mt-2 text-sm leading-6 text-neutral-500">
60
+ <%= @role.active? ?
61
+ t("lesli_shield.roles.detail_active_impact_#{members_plural}", count: members_count) :
62
+ t("lesli_shield.roles.detail_inactive_impact_#{members_plural}", count: members_count) %>
63
+ </p>
64
+ </div>
65
+ </section>
75
66
 
76
- <section id="general" class="rounded-2xl border border-neutral-200 bg-white p-5 shadow-sm sm:p-8">
77
- <%= render "form" %>
78
- </section>
67
+ <section id="general" class="rounded-2xl border border-neutral-200 bg-white p-5 shadow-sm sm:p-8">
68
+ <%= render "form" %>
69
+ </section>
79
70
 
80
- </div>
81
71
  </div>
82
72
  <% end %>
@@ -1,16 +1 @@
1
- <p style="color: green"><%= notice %></p>
2
-
3
- <% content_for :title, "Roles" %>
4
-
5
- <h1>Roles</h1>
6
-
7
- <div id="user_roles">
8
- <% @user_roles.each do |user_role| %>
9
- <%= render user_role %>
10
- <p>
11
- <%= link_to "Show this role", user_role %>
12
- </p>
13
- <% end %>
14
- </div>
15
-
16
- <%= link_to "New role", new_user_role_path %>
1
+ <%= render "lesli_shield/users/management-privileges" %>
@@ -1,74 +1,80 @@
1
- <%
2
- columns = [{
3
- label: "ID"
4
- }, {
5
- label: "Name"
6
- }, {
7
- label: "status"
8
- }]
9
- %>
1
+ <%= turbo_frame_tag dom_id(@user, :roles) do %>
2
+ <section class="w-full space-y-8 rounded-2xl border border-neutral-200 bg-white p-5 sm:p-8" aria-label="<%= t("lesli_shield.user_roles.title") %>">
3
+ <header>
4
+ <h2 class="text-lg font-semibold text-neutral-900"><%= t("lesli_shield.user_roles.title") %></h2>
5
+ <p class="mt-1 text-sm text-neutral-500"><%= t("lesli_shield.user_roles.description") %></p>
6
+ </header>
10
7
 
11
- <% roles = @user.account.roles.joins("
12
- LEFT JOIN lesli_shield_user_roles
13
- ON lesli_shield_user_roles.role_id = lesli_roles.id
14
- AND lesli_shield_user_roles.user_id = #{@user.id}
15
- ").select(
16
- "lesli_roles.*",
17
- "lesli_shield_user_roles.id AS user_role_id"
18
- )
19
- %>
8
+ <% if @role_error.present? %>
9
+ <p role="alert" class="text-sm text-danger-700"><%= @role_error %></p>
10
+ <% end %>
20
11
 
21
- <%= render(LesliView::Elements::Table.new(:columns => columns)) do |table| %>
22
- <% roles.each do |role| %>
23
- <% table.with_row do |row| %>
24
- <% row.with_cell do %>
25
- <%= role[:id] %>
26
- <% end %>
27
- <% row.with_cell do %>
28
- <%= role[:name] %>
29
- <% end %>
30
- <% row.with_cell do %>
31
- <%= button_to user_role_path(role),
32
- class: "mini-toggle #{'active' if role[:user_role_id].present?}",
33
- method: (role[:user_role_id].present? ? :delete : :patch) do %>
34
- <span class="mini-toggle-slider"></span>
35
- <% end %>
12
+ <% if @available_roles.any? %>
13
+ <%= form_with scope: :user_role, url: user_roles_path(@user),
14
+ builder: LesliView::Forms::Builder,
15
+ data: { turbo_frame: dom_id(@user, :roles) },
16
+ html: { "x-data": "{ roleId: '' }", class: "grid items-end gap-3 sm:grid-cols-[minmax(0,1fr)_auto] [&_.lesli-form-field]:mb-0" } do |form| %>
17
+ <%= form.field_control_select(:role_id,
18
+ @available_roles.map { |role| [role.name, role.id] },
19
+ label: t("lesli_shield.user_roles.role"), humanize: false,
20
+ options: { prompt: t("lesli_shield.user_roles.select_role") },
21
+ html_options: { required: true, "x-model": "roleId" }) %>
22
+ <%= form.field_control_button(t("lesli_shield.user_roles.add"),
23
+ { disabled: true, "x-bind:disabled": "!roleId", class: "h-11 w-full" }, icon: "add") %>
36
24
  <% end %>
25
+ <% else %>
26
+ <p class="text-sm text-neutral-500"><%= t("lesli_shield.user_roles.no_available_roles") %></p>
37
27
  <% end %>
38
- <% end %>
39
- <% end %>
40
28
 
41
- <style>
42
- .mini-toggle {
43
- position: relative;
44
- width: 40px;
45
- height: 20px;
46
- background: var(--lesli-color-neutral-300);
47
- border-radius: 9999px;
48
- border: none;
49
- cursor: pointer;
50
- padding: 0;
51
- transition: background 0.25s ease;
52
- display: inline-block;
53
- }
29
+ <div>
30
+ <h3 class="mb-3 flex items-center gap-2 text-sm font-semibold text-neutral-700">
31
+ <%= t("lesli_shield.user_roles.assigned") %>
32
+ <span class="rounded-full bg-neutral-100 px-2 py-0.5 text-xs text-neutral-500"><%= @user_roles.size %></span>
33
+ </h3>
54
34
 
55
- .mini-toggle.active {
56
- background: var(--lesli-color-primary); /* green */
57
- background: var(--lesli-color-primary)
58
- }
59
-
60
- .mini-toggle-slider {
61
- position: absolute;
62
- top: 2px;
63
- left: 2px;
64
- width: 16px;
65
- height: 16px;
66
- background: white;
67
- border-radius: 50%;
68
- transition: transform 0.25s ease;
69
- }
70
-
71
- .mini-toggle.active .mini-toggle-slider {
72
- transform: translateX(20px);
73
- }
74
- </style>
35
+ <% if @user_roles.empty? %>
36
+ <p class="rounded-xl border border-dashed border-neutral-200 p-6 text-center text-sm text-neutral-500">
37
+ <%= t("lesli_shield.user_roles.empty") %>
38
+ </p>
39
+ <% else %>
40
+ <ul class="divide-y divide-neutral-100 border-t border-neutral-200">
41
+ <% @user_roles.each do |assignment| %>
42
+ <% role = assignment.role %>
43
+ <li class="flex items-start justify-between gap-4 py-5">
44
+ <div class="min-w-0">
45
+ <div class="flex flex-wrap items-center gap-2">
46
+ <h4 class="break-words text-sm font-semibold text-neutral-900"><%= role.name %></h4>
47
+ <% unless role.active? %>
48
+ <span class="rounded-full bg-neutral-100 px-2 py-0.5 text-xs text-neutral-600">
49
+ <%= t("lesli_shield.user_roles.inactive") %>
50
+ </span>
51
+ <% end %>
52
+ </div>
53
+ <% if role.description.present? %>
54
+ <p class="mt-1 break-words text-sm leading-6 text-neutral-500"><%= role.description %></p>
55
+ <% end %>
56
+ <% unless role.active? %>
57
+ <p class="mt-1 text-xs text-neutral-500"><%= t("lesli_shield.user_roles.inactive_help") %></p>
58
+ <% end %>
59
+ </div>
60
+ <div class="shrink-0">
61
+ <% if role.account_id == current_user.account_id && role.permission_level.to_i <= current_user.max_level_permission %>
62
+ <%= render LesliView::Elements::Button.new(
63
+ t("lesli_shield.user_roles.remove"),
64
+ url: user_role_path(@user, assignment), method: :delete,
65
+ solid: false, small: true,
66
+ data: { turbo_frame: dom_id(@user, :roles),
67
+ turbo_confirm: t("lesli_shield.user_roles.confirm_remove",
68
+ role: role.name, user: @user.email) }
69
+ ) %>
70
+ <% else %>
71
+ <span class="text-xs text-neutral-500"><%= t("lesli_shield.user_roles.read_only") %></span>
72
+ <% end %>
73
+ </div>
74
+ </li>
75
+ <% end %>
76
+ </ul>
77
+ <% end %>
78
+ </div>
79
+ </section>
80
+ <% end %>
@@ -7,7 +7,7 @@
7
7
  <% tabs.with_tab(title:"information", icon:"info") do %>
8
8
  <%= render("information-form") %>
9
9
  <% end %>
10
- <% tabs.with_tab(title:"Privileges", icon:"security") do %>
10
+ <% tabs.with_tab(title: t("lesli_shield.user_roles.title"), icon:"security") do %>
11
11
  <%= render("management-privileges") %>
12
12
  <% end %>
13
13
 
@@ -36,6 +36,14 @@ en:
36
36
  view_update_description: "Choose a new password for your account and enter it twice to confirm it."
37
37
  view_update_title: "Create a new password"
38
38
  devise_registrations:
39
+ label_terms_html: "I accept the %{terms}."
40
+ link_terms: "Terms and conditions"
41
+ link_terms_new_tab: "Terms and conditions (opens a new tab)"
42
+ link_privacy: "Privacy policy"
43
+ link_privacy_new_tab: "Privacy policy (opens a new tab)"
44
+ message_terms_required: "You must accept the terms and conditions to register."
45
+ message_legal_documents_changed: "The legal documents have changed. Review them and confirm again."
46
+ view_privacy_notice_html: "Read the %{privacy} to learn how your data is used. We record the version presented; this is not consent to advertising or other optional uses."
39
47
  button_create_account: "Create account"
40
48
  button_creating_account: "Creating account…"
41
49
  button_login: "Log in"
@@ -46,7 +54,6 @@ en:
46
54
  message_too_many_attempts: "Too many account creation attempts. Try again later."
47
55
  view_already_have_an_account: "Already have an account?"
48
56
  view_description: "Enter your email address and choose a password to create your account."
49
- view_legal_notice: "By creating an account, you agree to the Terms and acknowledge the Global Privacy Statement."
50
57
  view_password_length: "Your password must contain between %{minimum} and %{maximum} characters."
51
58
  view_title: "Create an account to discover Lesli"
52
59
  devise_sessions:
@@ -36,6 +36,14 @@ es:
36
36
  view_update_description: "Elige una nueva contraseña para tu cuenta e ingrésala dos veces para confirmarla."
37
37
  view_update_title: "Crea una nueva contraseña"
38
38
  devise_registrations:
39
+ label_terms_html: "Acepto los %{terms}."
40
+ link_terms: "Términos y condiciones"
41
+ link_terms_new_tab: "Términos y condiciones (abre una pestaña nueva)"
42
+ link_privacy: "Política de privacidad"
43
+ link_privacy_new_tab: "Política de privacidad (abre una pestaña nueva)"
44
+ message_terms_required: "Debes aceptar los términos y condiciones para registrarte."
45
+ message_legal_documents_changed: "Los documentos legales cambiaron. Revísalos y vuelve a confirmar."
46
+ view_privacy_notice_html: "Consulta la %{privacy} para conocer cómo usamos tus datos. Conservamos la versión presentada; esto no supone consentimiento para publicidad u otros usos opcionales."
39
47
  button_create_account: "Crear cuenta"
40
48
  button_creating_account: "Creando cuenta…"
41
49
  button_login: "Iniciar sesión"
@@ -46,7 +54,6 @@ es:
46
54
  message_too_many_attempts: "Demasiados intentos de creación de cuenta. Inténtalo de nuevo más tarde."
47
55
  view_already_have_an_account: "¿Ya tienes cuenta?"
48
56
  view_description: "Ingresa tu correo electrónico y elige una contraseña para crear tu cuenta."
49
- view_legal_notice: "Al crear una cuenta, aceptas los Términos y reconoces la Declaración global de privacidad."
50
57
  view_password_length: "Tu contraseña debe contener entre %{minimum} y %{maximum} caracteres."
51
58
  view_title: "Crea una cuenta y descubre Lesli"
52
59
  devise_sessions:
@@ -0,0 +1,16 @@
1
+ en:
2
+ lesli_shield:
3
+ user_roles:
4
+ title: "Roles"
5
+ role: "Role"
6
+ select_role: "Select a role"
7
+ add: "Add role"
8
+ assigned: "Assigned roles"
9
+ remove: "Remove"
10
+ confirm_remove: "Remove the role %{role} from %{user}?"
11
+ empty: "This user has no assigned roles."
12
+ no_available_roles: "All available roles are already assigned."
13
+ description: "Roles determine what this user can see and do."
14
+ inactive: "Inactive"
15
+ inactive_help: "This role does not grant access while inactive."
16
+ read_only: "Read only"
@@ -0,0 +1,16 @@
1
+ es:
2
+ lesli_shield:
3
+ user_roles:
4
+ title: "Roles"
5
+ role: "Rol"
6
+ select_role: "Selecciona un rol"
7
+ add: "Agregar rol"
8
+ assigned: "Roles asignados"
9
+ remove: "Quitar"
10
+ confirm_remove: "¿Quitar el rol %{role} de %{user}?"
11
+ empty: "Este usuario no tiene roles asignados."
12
+ no_available_roles: "Todos los roles disponibles ya están asignados."
13
+ description: "Los roles determinan qué puede ver y hacer este usuario."
14
+ inactive: "Inactivo"
15
+ inactive_help: "Este rol no concede acceso mientras esté inactivo."
16
+ read_only: "Solo lectura"
data/config/routes.rb CHANGED
@@ -60,7 +60,7 @@ LesliShield::Engine.routes.draw do
60
60
  resources :sessions, only: [:index, :destroy]
61
61
 
62
62
  # assign and remove roles to users
63
- resources :roles, only: [:index, :create, :update, :destroy]
63
+ resources :roles, only: [:index, :create, :destroy]
64
64
 
65
65
  # shortcuts
66
66
  resources :shortcuts, only: [:index, :create, :update, :destroy]