lesli_shield 1.1.6 → 1.1.8

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 (110) hide show
  1. checksums.yaml +4 -4
  2. data/Rakefile +3 -0
  3. data/app/assets/stylesheets/lesli_shield/application.css +1222 -1
  4. data/app/assets/stylesheets/lesli_shield/confirmations.css +917 -18
  5. data/app/assets/stylesheets/lesli_shield/confirmations.tailwind.css +918 -0
  6. data/app/assets/stylesheets/lesli_shield/invitations.css +1008 -0
  7. data/app/assets/stylesheets/lesli_shield/passwords.css +872 -18
  8. data/app/assets/stylesheets/lesli_shield/passwords.tailwind.css +873 -0
  9. data/app/assets/stylesheets/lesli_shield/registrations.css +904 -832
  10. data/app/assets/stylesheets/lesli_shield/registrations.tailwind.css +908 -0
  11. data/app/assets/stylesheets/lesli_shield/sessions.css +984 -32
  12. data/app/assets/stylesheets/lesli_shield/sessions.tailwind.css +983 -1
  13. data/app/controllers/lesli_shield/invites_controller.rb +100 -49
  14. data/app/controllers/lesli_shield/profile/passwords_controller.rb +119 -0
  15. data/app/controllers/lesli_shield/profiles_controller.rb +69 -0
  16. data/app/controllers/lesli_shield/role/actions_controller.rb +134 -38
  17. data/app/controllers/lesli_shield/roles_controller.rb +114 -141
  18. data/app/controllers/lesli_shield/sessions_controller.rb +1 -2
  19. data/app/controllers/lesli_shield/users_controller.rb +11 -4
  20. data/app/controllers/users/confirmations_controller.rb +162 -49
  21. data/app/controllers/users/invitations_controller.rb +101 -0
  22. data/app/controllers/users/passwords_controller.rb +211 -28
  23. data/app/controllers/users/registrations_controller.rb +108 -83
  24. data/app/controllers/users/sessions_controller.rb +124 -84
  25. data/app/interfaces/lesli_shield/authorization_interface.rb +2 -2
  26. data/app/jobs/lesli_shield/invitation_delivery_job.rb +123 -0
  27. data/app/mailers/lesli_shield/devise_mailer.rb +73 -17
  28. data/app/mailers/lesli_shield/invitation_mailer.rb +58 -0
  29. data/app/models/concerns/lesli_shield/role_management.rb +70 -0
  30. data/app/models/concerns/lesli_shield/user_authentication.rb +54 -0
  31. data/app/models/concerns/lesli_shield/user_security.rb +22 -19
  32. data/app/models/lesli_shield/account.rb +4 -1
  33. data/app/models/lesli_shield/invite.rb +183 -12
  34. data/app/models/lesli_shield/user/role.rb +1 -1
  35. data/app/models/lesli_shield/user.rb +5 -2
  36. data/app/services/lesli_shield/invitation_audit.rb +34 -0
  37. data/app/services/lesli_shield/invitation_email_policy.rb +64 -0
  38. data/app/services/lesli_shield/invitation_service.rb +405 -0
  39. data/app/services/lesli_shield/invite_service.rb +34 -5
  40. data/app/services/lesli_shield/profile/password_service.rb +47 -0
  41. data/app/services/lesli_shield/profile_service.rb +25 -0
  42. data/app/services/lesli_shield/role_action_service.rb +37 -92
  43. data/app/services/lesli_shield/role_audit.rb +42 -0
  44. data/app/services/lesli_shield/role_permission_service.rb +347 -0
  45. data/app/services/lesli_shield/role_privilege_deployment_service.rb +79 -0
  46. data/app/services/lesli_shield/role_privilege_service.rb +69 -105
  47. data/app/services/lesli_shield/role_service.rb +431 -0
  48. data/app/services/lesli_shield/user_registration_service.rb +41 -74
  49. data/app/services/lesli_shield/user_session_service.rb +1 -1
  50. data/app/services/lesli_shield/user_validator_service.rb +37 -39
  51. data/app/views/devise/confirmations/new.html.erb +58 -12
  52. data/app/views/devise/confirmations/show.html.erb +27 -60
  53. data/app/views/devise/passwords/edit.html.erb +59 -25
  54. data/app/views/devise/passwords/new.html.erb +61 -26
  55. data/app/views/devise/registrations/new.html.erb +83 -56
  56. data/app/views/devise/sessions/new.html.erb +58 -41
  57. data/app/views/devise/shared/_application-devise-simple.erb +18 -19
  58. data/app/views/devise/shared/_demo.html.erb +8 -6
  59. data/app/views/devise/shared/_error_messages.html.erb +45 -10
  60. data/app/views/devise/shared/_links.html.erb +10 -20
  61. data/app/views/lesli_shield/invites/_form.html.erb +64 -7
  62. data/app/views/lesli_shield/invites/_invite.html.erb +55 -2
  63. data/app/views/lesli_shield/invites/_invite_actions.html.erb +34 -0
  64. data/app/views/lesli_shield/invites/_status_badge.html.erb +13 -0
  65. data/app/views/lesli_shield/invites/index.html.erb +119 -62
  66. data/app/views/lesli_shield/invites/new.html.erb +11 -36
  67. data/app/views/lesli_shield/invites/show.html.erb +13 -52
  68. data/app/views/lesli_shield/profiles/_information-form.html.erb +11 -0
  69. data/app/views/lesli_shield/profiles/_password-form.html.erb +68 -0
  70. data/app/views/lesli_shield/profiles/show.html.erb +26 -0
  71. data/app/views/lesli_shield/role/actions/_custom_actions.html.erb +24 -0
  72. data/app/views/lesli_shield/role/actions/_deployment_status.html.erb +14 -0
  73. data/app/views/lesli_shield/role/actions/_matrix.html.erb +69 -0
  74. data/app/views/lesli_shield/role/actions/_permissions.html.erb +95 -0
  75. data/app/views/lesli_shield/role/actions/_toggle.html.erb +34 -0
  76. data/app/views/lesli_shield/role/actions/index.html.erb +14 -10
  77. data/app/views/lesli_shield/roles/_deployment_badge.html.erb +15 -0
  78. data/app/views/lesli_shield/roles/_empty_state.html.erb +20 -0
  79. data/app/views/lesli_shield/roles/_field_errors.html.erb +5 -0
  80. data/app/views/lesli_shield/roles/_filters.html.erb +66 -0
  81. data/app/views/lesli_shield/roles/_form.html.erb +149 -18
  82. data/app/views/lesli_shield/roles/_management_menu.html.erb +37 -0
  83. data/app/views/lesli_shield/roles/_pagination.html.erb +43 -0
  84. data/app/views/lesli_shield/roles/_role_list.html.erb +116 -0
  85. data/app/views/lesli_shield/roles/_status_badge.html.erb +11 -0
  86. data/app/views/lesli_shield/roles/_type_badge.html.erb +9 -0
  87. data/app/views/lesli_shield/roles/index.html.erb +15 -38
  88. data/app/views/lesli_shield/roles/new.html.erb +11 -0
  89. data/app/views/lesli_shield/roles/show.html.erb +79 -7
  90. data/app/views/lesli_shield/users/_information-form.html.erb +15 -1
  91. data/app/views/users/invitations/show.html.erb +142 -0
  92. data/app/views/users/invitations/unavailable.html.erb +19 -0
  93. data/config/initializers/devise.rb +52 -328
  94. data/config/locales/devise.en.yml +8 -0
  95. data/config/locales/devise.es.yml +8 -0
  96. data/config/locales/translations.en.yml +314 -16
  97. data/config/locales/translations.es.yml +314 -16
  98. data/config/routes.rb +14 -3
  99. data/db/migrate/v1/0801120110_create_lesli_shield_invites.rb +40 -6
  100. data/lib/lesli_shield/engine.rb +42 -4
  101. data/lib/lesli_shield/router.rb +62 -18
  102. data/lib/lesli_shield/version.rb +2 -2
  103. data/lib/tasks/lesli_shield_tasks.rake +1 -1
  104. data/readme.md +17 -3
  105. metadata +63 -8
  106. data/app/assets/config/lesli_shield_manifest.js +0 -48
  107. data/app/assets/stylesheets/lesli_shield/application.tailwind.css +0 -2
  108. data/app/mailers/lesli_shield/invitation.html.erb +0 -23
  109. data/app/views/lesli_shield/invites/edit.html.erb +0 -12
  110. data/app/views/lesli_shield/role/actions/_form.html.erb +0 -75
@@ -1,2 +1,55 @@
1
- <div id="<%= dom_id invite %>">
2
- </div>
1
+ <%
2
+ format_time = lambda do |value|
3
+ value.present? ? I18n.l(value, format: :long) : "—"
4
+ end
5
+
6
+ inviter_name = invite.invited_by.full_name.to_s.strip.presence ||
7
+ invite.invited_by.email
8
+
9
+ details = [
10
+ [I18n.t("lesli_shield.invites.detail_email"), invite.email],
11
+ [
12
+ I18n.t("lesli_shield.invites.detail_name"),
13
+ invite.full_name.presence || I18n.t("lesli_shield.invites.value_not_available")
14
+ ],
15
+ [
16
+ I18n.t("lesli_shield.invites.detail_role"),
17
+ invite.role&.name || I18n.t("lesli_shield.invites.value_not_available")
18
+ ],
19
+ [I18n.t("lesli_shield.invites.detail_invited_by"), inviter_name],
20
+ [I18n.t("lesli_shield.invites.detail_sent_at"), format_time.call(invite.sent_at)],
21
+ [I18n.t("lesli_shield.invites.detail_expires_at"), format_time.call(invite.expires_at)],
22
+ [I18n.t("lesli_shield.invites.detail_accepted_at"), format_time.call(invite.accepted_at)],
23
+ [I18n.t("lesli_shield.invites.detail_cancelled_at"), format_time.call(invite.cancelled_at)]
24
+ ]
25
+ %>
26
+
27
+ <article id="<%= dom_id invite %>" class="overflow-hidden rounded-2xl border border-slate-200 bg-white shadow-sm">
28
+ <div class="flex flex-col gap-3 border-b border-slate-200 bg-slate-50 px-6 py-5 sm:flex-row sm:items-center sm:justify-between">
29
+ <div>
30
+ <p class="text-sm font-medium text-slate-500">
31
+ <%= I18n.t("lesli_shield.invites.detail_recipient") %>
32
+ </p>
33
+ <p class="mt-1 text-lg font-semibold text-slate-900">
34
+ <%= invite.full_name.presence || invite.email %>
35
+ </p>
36
+ </div>
37
+ <%= render "status_badge", invite: invite %>
38
+ </div>
39
+
40
+ <dl class="grid grid-cols-1 sm:grid-cols-2">
41
+ <% details.each do |label, value| %>
42
+ <div class="border-b border-slate-100 px-6 py-5 sm:odd:border-r">
43
+ <dt class="text-sm font-medium text-slate-500"><%= label %></dt>
44
+ <dd class="mt-1 break-words text-sm font-semibold text-slate-900"><%= value %></dd>
45
+ </div>
46
+ <% end %>
47
+ </dl>
48
+
49
+ <div class="px-6 py-5">
50
+ <h2 class="text-sm font-medium text-slate-500">
51
+ <%= I18n.t("lesli_shield.invites.detail_message") %>
52
+ </h2>
53
+ <p class="mt-2 whitespace-pre-wrap text-sm leading-6 text-slate-700"><%= invite.notes.presence || "—" %></p>
54
+ </div>
55
+ </article>
@@ -0,0 +1,34 @@
1
+ <%
2
+ show_view = local_assigns.fetch(:show_view, false)
3
+ action_classes = "inline-flex h-9 items-center justify-center rounded-lg border px-3 text-xs font-semibold transition focus:outline-none focus:ring-4"
4
+ %>
5
+
6
+ <div class="flex flex-wrap items-center gap-2">
7
+ <% if show_view %>
8
+ <%= link_to I18n.t("lesli_shield.invites.action_view"),
9
+ invite_path(invite),
10
+ class: "#{action_classes} border-slate-200 bg-white text-slate-700 hover:bg-slate-50 focus:ring-slate-500/10" %>
11
+ <% end %>
12
+
13
+ <% if invite.resend_available? %>
14
+ <%= button_to I18n.t("lesli_shield.invites.action_resend"),
15
+ resend_invite_path(invite),
16
+ method: :post,
17
+ form: { class: "inline" },
18
+ class: "#{action_classes} border-emerald-200 bg-emerald-50 text-emerald-700 hover:bg-emerald-100 focus:ring-emerald-500/10",
19
+ data: {
20
+ turbo_confirm: I18n.t("lesli_shield.invites.confirm_resend")
21
+ } %>
22
+ <% end %>
23
+
24
+ <% if invite.cancellable? %>
25
+ <%= button_to I18n.t("lesli_shield.invites.action_cancel"),
26
+ cancel_invite_path(invite),
27
+ method: :patch,
28
+ form: { class: "inline" },
29
+ class: "#{action_classes} border-rose-200 bg-rose-50 text-rose-700 hover:bg-rose-100 focus:ring-rose-500/10",
30
+ data: {
31
+ turbo_confirm: I18n.t("lesli_shield.invites.confirm_cancel")
32
+ } %>
33
+ <% end %>
34
+ </div>
@@ -0,0 +1,13 @@
1
+ <%
2
+ status = invite.lifecycle_status
3
+ status_classes = {
4
+ "pending" => "bg-amber-50 text-amber-700 ring-amber-600/20",
5
+ "accepted" => "bg-emerald-50 text-emerald-700 ring-emerald-600/20",
6
+ "cancelled" => "bg-slate-100 text-slate-600 ring-slate-500/20",
7
+ "expired" => "bg-rose-50 text-rose-700 ring-rose-600/20"
8
+ }
9
+ %>
10
+
11
+ <span class="inline-flex items-center rounded-full px-2.5 py-1 text-xs font-semibold ring-1 ring-inset <%= status_classes.fetch(status) %>">
12
+ <%= I18n.t("lesli_shield.invites.statuses_#{status}") %>
13
+ </span>
@@ -1,66 +1,123 @@
1
- <%#
2
-
3
- Lesli
4
-
5
- Copyright (c) 2023, Lesli Technologies, S. A.
6
-
7
- This program is free software: you can redistribute it and/or modify
8
- it under the terms of the GNU General Public License as published by
9
- the Free Software Foundation, either version 3 of the License, or
10
- (at your option) any later version.
11
-
12
- This program is distributed in the hope that it will be useful,
13
- but WITHOUT ANY WARRANTY; without even the implied warranty of
14
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
- GNU General Public License for more details.
16
-
17
- You should have received a copy of the GNU General Public License
18
- along with this program. If not, see http://www.gnu.org/licenses/.
19
-
20
- Lesli · Ruby on Rails SaaS Development Framework.
1
+ <%
2
+ records = @invites.fetch(:records)
3
+ status_filters = [
4
+ [nil, I18n.t("lesli_shield.invites.filter_all")],
5
+ *LesliShield::InviteService::STATUS_FILTERS.map do |status|
6
+ [status, I18n.t("lesli_shield.invites.statuses_#{status}")]
7
+ end
8
+ ]
9
+ %>
21
10
 
22
- Made with ♥ by https://www.lesli.tech
23
- Building a better future, one line of code at a time.
11
+ <%= render LesliView::Layout::Container.new("shield-invites") do %>
12
+ <%= render LesliView::Components::Header.new(
13
+ I18n.t("lesli_shield.invites.title"),
14
+ I18n.t("lesli_shield.invites.subtitle")
15
+ ) do %>
16
+ <%= link_to new_invite_path,
17
+ class: "inline-flex h-10 items-center justify-center gap-2 rounded-xl bg-sky-600 px-4 text-sm font-semibold text-white shadow-sm transition hover:bg-sky-700 focus:outline-none focus:ring-4 focus:ring-sky-500/20" do %>
18
+ <span class="material-symbols" aria-hidden="true">person_add</span>
19
+ <span><%= I18n.t("lesli_shield.invites.action_create") %></span>
20
+ <% end %>
21
+ <% end %>
24
22
 
25
- @contact hello@lesli.tech
26
- @website https://www.lesli.tech
27
- @license GPLv3 http://www.gnu.org/licenses/gpl-3.0.en.html
23
+ <nav
24
+ class="mb-6 flex flex-wrap gap-2"
25
+ aria-label="<%= I18n.t("lesli_shield.invites.filters_label") %>">
26
+ <% status_filters.each do |status, label| %>
27
+ <%
28
+ active = @status_filter == status
29
+ filter_classes = class_names(
30
+ "inline-flex items-center rounded-full border px-3 py-1.5 text-sm font-medium transition focus:outline-none focus:ring-4 focus:ring-sky-500/10",
31
+ active ?
32
+ "border-sky-600 bg-sky-600 text-white" :
33
+ "border-slate-200 bg-white text-slate-600 hover:border-slate-300 hover:text-slate-900"
34
+ )
35
+ %>
36
+ <%= link_to label,
37
+ invites_path(status: status),
38
+ class: filter_classes,
39
+ aria: { current: active ? "page" : nil } %>
40
+ <% end %>
41
+ </nav>
28
42
 
29
- // · ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~
30
- // ·
31
- %>
32
- <%
33
- columns = [{
34
- field: "id",
35
- label: "ID",
36
- sort: true
37
- }, {
38
- field: "full_name",
39
- label: "Name",
40
- sort: true
41
- }, {
42
- field: "email",
43
- label: "Email",
44
- sort: true
45
- }, {
46
- field: "telephone",
47
- label: "Telephone",
48
- sort: true
49
- }, {
50
- field: "status",
51
- label: "status",
52
- sort: true
53
- }]
54
- %>
55
- <%= render LesliView::Layout::Container.new('shield-invites') do %>
56
- <%= render LesliView::Components::Header.new('Invites') do %>
57
- <%= render(LesliView::Elements::Button.new('Create invitation', url: new_invite_path, icon: "add", solid:true)) %>
58
- <%= render(LesliView::Elements::Button.new(icon: 'refresh')) %>
43
+ <% if records.any? %>
44
+ <div class="overflow-hidden rounded-2xl border border-slate-200 bg-white shadow-sm">
45
+ <div class="overflow-x-auto">
46
+ <table class="min-w-full divide-y divide-slate-200">
47
+ <thead class="bg-slate-50">
48
+ <tr>
49
+ <% %w[recipient role status sent_at expires_at actions].each do |column| %>
50
+ <th scope="col" class="px-5 py-3 text-left text-xs font-semibold uppercase tracking-wide text-slate-500">
51
+ <%= I18n.t("lesli_shield.invites.column_#{column}") %>
52
+ </th>
53
+ <% end %>
54
+ </tr>
55
+ </thead>
56
+ <tbody class="divide-y divide-slate-100 bg-white">
57
+ <% records.each do |invite| %>
58
+ <tr class="transition hover:bg-slate-50/80">
59
+ <td class="whitespace-nowrap px-5 py-4">
60
+ <%= link_to invite_path(invite), class: "block focus:outline-none" do %>
61
+ <span class="block text-sm font-semibold text-slate-900">
62
+ <%= invite.full_name.presence || invite.email %>
63
+ </span>
64
+ <% if invite.full_name.present? %>
65
+ <span class="mt-0.5 block text-sm text-slate-500"><%= invite.email %></span>
66
+ <% end %>
67
+ <% end %>
68
+ </td>
69
+ <td class="whitespace-nowrap px-5 py-4 text-sm text-slate-600">
70
+ <%= invite.role&.name || I18n.t("lesli_shield.invites.value_not_available") %>
71
+ </td>
72
+ <td class="whitespace-nowrap px-5 py-4">
73
+ <%= render "status_badge", invite: invite %>
74
+ </td>
75
+ <td class="whitespace-nowrap px-5 py-4 text-sm text-slate-600">
76
+ <%= invite.sent_at.present? ? I18n.l(invite.sent_at, format: :short) : "—" %>
77
+ </td>
78
+ <td class="whitespace-nowrap px-5 py-4 text-sm text-slate-600">
79
+ <%= invite.expires_at.present? ? I18n.l(invite.expires_at, format: :short) : "—" %>
80
+ </td>
81
+ <td class="whitespace-nowrap px-5 py-4">
82
+ <%= render "invite_actions", invite: invite, show_view: true %>
83
+ </td>
84
+ </tr>
85
+ <% end %>
86
+ </tbody>
87
+ </table>
88
+ </div>
89
+ </div>
90
+ <% else %>
91
+ <%
92
+ if @status_filter.present?
93
+ empty_title = I18n.t("lesli_shield.invites.empty_filtered_title")
94
+ empty_description = I18n.t(
95
+ "lesli_shield.invites.empty_filtered_description"
96
+ )
97
+ empty_action = I18n.t(
98
+ "lesli_shield.invites.empty_filtered_action"
99
+ )
100
+ empty_action_path = invites_path
101
+ else
102
+ empty_title = I18n.t("lesli_shield.invites.empty_title")
103
+ empty_description = I18n.t(
104
+ "lesli_shield.invites.empty_description"
105
+ )
106
+ empty_action = I18n.t("lesli_shield.invites.empty_action")
107
+ empty_action_path = new_invite_path
108
+ end
109
+ %>
110
+ <section class="rounded-2xl border border-dashed border-slate-300 bg-white px-6 py-16 text-center shadow-sm">
111
+ <span class="material-symbols mx-auto mb-4 block text-5xl text-slate-300" aria-hidden="true">person_add</span>
112
+ <h2 class="text-lg font-semibold text-slate-900">
113
+ <%= empty_title %>
114
+ </h2>
115
+ <p class="mx-auto mt-2 max-w-md text-sm leading-6 text-slate-500">
116
+ <%= empty_description %>
117
+ </p>
118
+ <%= link_to empty_action,
119
+ empty_action_path,
120
+ class: "mt-6 inline-flex h-10 items-center justify-center rounded-xl bg-sky-600 px-4 text-sm font-semibold text-white shadow-sm transition hover:bg-sky-700 focus:outline-none focus:ring-4 focus:ring-sky-500/20" %>
121
+ </section>
59
122
  <% end %>
60
- <%= render LesliView::Components::Toolbar.new() %>
61
- <%= render(LesliView::Elements::Table.new(
62
- columns: columns,
63
- records: @invites[:records],
64
- link: lambda {|invite| invite_path(invite.id) }
65
- )) %>
66
- <% end %>
123
+ <% end %>
@@ -1,36 +1,11 @@
1
- <%#
2
-
3
- Lesli
4
-
5
- Copyright (c) 2023, Lesli Technologies, S. A.
6
-
7
- This program is free software: you can redistribute it and/or modify
8
- it under the terms of the GNU General Public License as published by
9
- the Free Software Foundation, either version 3 of the License, or
10
- (at your option) any later version.
11
-
12
- This program is distributed in the hope that it will be useful,
13
- but WITHOUT ANY WARRANTY; without even the implied warranty of
14
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
- GNU General Public License for more details.
16
-
17
- You should have received a copy of the GNU General Public License
18
- along with this program. If not, see http://www.gnu.org/licenses/.
19
-
20
- Lesli · Ruby on Rails SaaS Development Framework.
21
-
22
- Made with ♥ by https://www.lesli.tech
23
- Building a better future, one line of code at a time.
24
-
25
- @contact hello@lesli.tech
26
- @website https://www.lesli.tech
27
- @license GPLv3 http://www.gnu.org/licenses/gpl-3.0.en.html
28
-
29
- // · ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~
30
- // ·
31
- %>
32
-
33
- <%= render LesliView::Layout::Container.new('shield-invites') do %>
34
- <%= render LesliView::Components::Header.new('Invites')%>
35
- <%= render "form" %>
36
- <% end %>
1
+ <%= render LesliView::Layout::Container.new("shield-invites") do %>
2
+ <%= render LesliView::Components::Header.new(
3
+ I18n.t("lesli_shield.invites.new_title"),
4
+ I18n.t("lesli_shield.invites.new_description"),
5
+ back: invites_path
6
+ ) %>
7
+
8
+ <div class="max-w-2xl">
9
+ <%= render "form" %>
10
+ </div>
11
+ <% end %>
@@ -1,54 +1,15 @@
1
- <%#
2
-
3
- Lesli
4
-
5
- Copyright (c) 2023, Lesli Technologies, S. A.
6
-
7
- This program is free software: you can redistribute it and/or modify
8
- it under the terms of the GNU General Public License as published by
9
- the Free Software Foundation, either version 3 of the License, or
10
- (at your option) any later version.
11
-
12
- This program is distributed in the hope that it will be useful,
13
- but WITHOUT ANY WARRANTY; without even the implied warranty of
14
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
- GNU General Public License for more details.
16
-
17
- You should have received a copy of the GNU General Public License
18
- along with this program. If not, see http://www.gnu.org/licenses/.
19
-
20
- Lesli · Ruby on Rails SaaS Development Framework.
21
-
22
- Made with ♥ by https://www.lesli.tech
23
- Building a better future, one line of code at a time.
24
-
25
- @contact hello@lesli.tech
26
- @website https://www.lesli.tech
27
- @license GPLv3 http://www.gnu.org/licenses/gpl-3.0.en.html
28
-
29
- // · ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~
30
- // ·
1
+ <%
2
+ recipient = @invite.full_name.presence || @invite.email
31
3
  %>
32
- <%= render LesliView::Layout::Container.new('shield-invites') do %>
33
- <%= render LesliView::Components::Header.new("Invite for #{ @invite.full_name.presence || @invite.email }") do %>
34
- <%= render(LesliView::Elements::Button.new(
35
- 'Send invitation',
36
- success:true,
37
- solid:true,
38
- icon:'send',
39
- url: invite_path(@invite),
40
- method: :put,
41
- params: { invite: { status: :sent } }
42
- )) %>
43
- <%= render(LesliView::Elements::Button.new(
44
- 'Cancel invitation',
45
- danger:true,
46
- solid:true,
47
- icon:'cancel',
48
- url: invite_path(@invite),
49
- method: :put,
50
- params: { invite: { status: :cancelled } }
51
- )) %>
4
+
5
+ <%= render LesliView::Layout::Container.new("shield-invites") do %>
6
+ <%= render LesliView::Components::Header.new(
7
+ I18n.t("lesli_shield.invites.detail_title", recipient: recipient),
8
+ nil,
9
+ back: invites_path
10
+ ) do %>
11
+ <%= render "invite_actions", invite: @invite, show_view: false %>
52
12
  <% end %>
53
- <%= render "form" %>
54
- <% end %>
13
+
14
+ <%= render "invite", invite: @invite %>
15
+ <% end %>
@@ -0,0 +1,11 @@
1
+ <div id="shield-profile-information-form">
2
+ <% if @user.errors.any? %>
3
+ <div role="alert">
4
+ <% @user.errors.full_messages.each do |message| %>
5
+ <p><%= message %></p>
6
+ <% end %>
7
+ </div>
8
+ <% end %>
9
+
10
+ <%= render "lesli_shield/users/information-form", form_url: profile_path %>
11
+ </div>
@@ -0,0 +1,68 @@
1
+ <div id="shield-profile-password-form" class="max-w-2xl">
2
+ <p class="mb-6 text-sm leading-6 text-slate-600">
3
+ <%= I18n.t("lesli_shield.profiles.password_description") %>
4
+ </p>
5
+
6
+ <%= form_with(
7
+ model: user,
8
+ url: profile_password_path,
9
+ method: :patch,
10
+ builder: LesliView::Forms::Builder
11
+ ) do |form| %>
12
+ <%= form.fieldset do %>
13
+ <%= form.field_control_password(
14
+ :current_password,
15
+ label: I18n.t("lesli_shield.profiles.current_password"),
16
+ message: user.errors[:current_password].to_sentence.presence,
17
+ category: user.errors[:current_password].any? ? :danger : nil,
18
+ icon: "lock",
19
+ required: true,
20
+ autocomplete: "current-password",
21
+ value: ""
22
+ ) %>
23
+
24
+ <%= form.field_control_password(
25
+ :password,
26
+ label: I18n.t("lesli_shield.profiles.new_password"),
27
+ message: user.errors[:password].to_sentence.presence ||
28
+ I18n.t(
29
+ "lesli_shield.profiles.password_hint",
30
+ minimum: Devise.password_length.min,
31
+ maximum: Devise.password_length.max
32
+ ),
33
+ category: user.errors[:password].any? ? :danger : nil,
34
+ icon: "key",
35
+ required: true,
36
+ autocomplete: "new-password",
37
+ minlength: Devise.password_length.min,
38
+ maxlength: Devise.password_length.max,
39
+ value: ""
40
+ ) %>
41
+
42
+ <%= form.field_control_password(
43
+ :password_confirmation,
44
+ label: I18n.t("lesli_shield.profiles.password_confirmation"),
45
+ message: user.errors[:password_confirmation].to_sentence.presence,
46
+ category: user.errors[:password_confirmation].any? ? :danger : nil,
47
+ icon: "key",
48
+ required: true,
49
+ autocomplete: "new-password",
50
+ minlength: Devise.password_length.min,
51
+ maxlength: Devise.password_length.max,
52
+ value: ""
53
+ ) %>
54
+
55
+ <%= form.field_control_button(
56
+ I18n.t("lesli_shield.profiles.change_password"),
57
+ {
58
+ data: {
59
+ turbo_submits_with: I18n.t(
60
+ "lesli_shield.profiles.changing_password"
61
+ )
62
+ }
63
+ },
64
+ icon: "key"
65
+ ) %>
66
+ <% end %>
67
+ <% end %>
68
+ </div>
@@ -0,0 +1,26 @@
1
+ <%= render LesliView::Layout::Container.new("shield-profile-show") do %>
2
+ <%= render "lesli_shield/users/information-card" %>
3
+
4
+ <%= render LesliView::Components::Tabs.new(
5
+ active_tab: @active_profile_tab.presence || params[:tab].presence_in(%w[information security]) || "information"
6
+ ) do |tabs| %>
7
+ <% tabs.with_tab(
8
+ id: "information",
9
+ title: I18n.t("lesli_shield.profiles.information"),
10
+ icon: "info"
11
+ ) do %>
12
+ <%= render "lesli_shield/profiles/information-form" %>
13
+ <% end %>
14
+
15
+ <% tabs.with_tab(
16
+ id: "security",
17
+ title: I18n.t("lesli_shield.profiles.security"),
18
+ icon: "lock"
19
+ ) do %>
20
+ <%= render(
21
+ "lesli_shield/profiles/password-form",
22
+ user: @user
23
+ ) %>
24
+ <% end %>
25
+ <% end %>
26
+ <% end %>
@@ -0,0 +1,24 @@
1
+ <div class="divide-y divide-slate-200 border-t border-slate-200" data-custom-actions>
2
+ <h3 class="px-4 py-3 text-sm font-semibold text-slate-900 sm:px-5">
3
+ <%= t("lesli_shield.roles.permissions_custom_actions") %>
4
+ </h3>
5
+ <% resources.each do |resource| %>
6
+ <fieldset class="px-4 py-5 sm:px-5">
7
+ <legend class="w-full">
8
+ <span class="block text-sm font-semibold text-slate-900"><%= resource[:label] %></span>
9
+ <span class="mt-0.5 block break-all font-mono text-xs text-slate-500"><%= resource[:route] %></span>
10
+ </legend>
11
+ <div class="mt-4 grid gap-3 sm:grid-cols-2 xl:grid-cols-3">
12
+ <% resource[:actions].reject { |action| action[:standard] }.each do |action| %>
13
+ <div class="flex min-h-14 items-start gap-3 rounded-xl border border-slate-200 bg-white p-3">
14
+ <%= render "toggle", action: action %>
15
+ <span class="min-w-0 flex-1">
16
+ <span class="block text-sm font-semibold text-slate-900"><%= action[:display_label] %></span>
17
+ <span class="mt-0.5 block break-all font-mono text-xs text-slate-500"><%= action[:action] %></span>
18
+ </span>
19
+ </div>
20
+ <% end %>
21
+ </div>
22
+ </fieldset>
23
+ <% end %>
24
+ </div>
@@ -0,0 +1,14 @@
1
+ <div
2
+ id="role-permission-deployment-status"
3
+ class="flex min-h-10 items-center gap-2 rounded-xl border border-slate-200 bg-white px-3 shadow-sm"
4
+ >
5
+ <%= render "lesli_shield/roles/deployment_badge", role: @role %>
6
+ <% if @role.deployed_at.present? %>
7
+ <time
8
+ datetime="<%= @role.deployed_at.iso8601 %>"
9
+ class="hidden text-xs text-slate-500 sm:inline"
10
+ >
11
+ <%= l(@role.deployed_at, format: :short) %>
12
+ </time>
13
+ <% end %>
14
+ </div>
@@ -0,0 +1,69 @@
1
+ <%
2
+ standard_action_names = LesliShield::RolePermissionService::STANDARD_ACTION_ORDER
3
+ %>
4
+
5
+ <% @permission_matrix.each do |engine| %>
6
+ <%
7
+ engine_actions = engine[:resources].flat_map { |resource| resource[:actions] }
8
+ standard_resources = engine[:resources].select { |resource| resource[:actions].any? { |action| action[:standard] } }
9
+ custom_resources = engine[:resources].select { |resource| resource[:actions].any? { |action| !action[:standard] } }
10
+ %>
11
+ <section
12
+ id="permission-engine-<%= engine[:engine].parameterize %>"
13
+ class="scroll-mt-4 overflow-hidden rounded-xl border border-slate-200 bg-white shadow-sm"
14
+ >
15
+ <header class="flex items-center justify-between gap-4 border-b border-slate-200 bg-slate-50 px-4 py-4 sm:px-5">
16
+ <h2 class="font-semibold text-slate-900"><%= engine[:label] %></h2>
17
+ <p class="text-right text-xs text-slate-600">
18
+ <%= t(
19
+ "lesli_shield.roles.permissions_module_summary",
20
+ selected: engine_actions.count { |action| action[:assigned] },
21
+ total: engine_actions.size
22
+ ) %>
23
+ </p>
24
+ </header>
25
+
26
+ <% if standard_resources.any? %>
27
+ <table class="block w-full xl:table">
28
+ <thead class="hidden bg-slate-50 xl:table-header-group">
29
+ <tr>
30
+ <th scope="col" class="px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-slate-500 sm:px-5">
31
+ <%= t("lesli_shield.roles.permissions_resource") %>
32
+ </th>
33
+ <% standard_action_names.each do |action_name| %>
34
+ <th scope="col" class="px-2 py-3 text-center text-xs font-semibold uppercase tracking-wide text-slate-500">
35
+ <%= t("lesli_shield.roles.permissions_standard_actions_#{action_name}") %>
36
+ </th>
37
+ <% end %>
38
+ </tr>
39
+ </thead>
40
+ <tbody class="block divide-y divide-slate-200 xl:table-row-group">
41
+ <% standard_resources.each do |resource| %>
42
+ <tr class="block p-4 xl:table-row xl:p-0">
43
+ <th scope="row" class="block pb-3 text-left xl:table-cell xl:px-5 xl:py-4 xl:align-middle">
44
+ <span class="block text-sm font-semibold text-slate-900"><%= resource[:label] %></span>
45
+ <span class="mt-0.5 block break-all font-mono text-xs font-normal text-slate-500"><%= resource[:route] %></span>
46
+ </th>
47
+ <% standard_action_names.each do |action_name| %>
48
+ <% action = resource[:actions].find { |candidate| candidate[:action] == action_name } %>
49
+ <td class="block py-1 xl:table-cell xl:px-2 xl:py-4 xl:text-center xl:align-middle">
50
+ <% if action %>
51
+ <div class="flex min-h-11 items-center justify-between gap-3 rounded-lg px-2 py-2 transition hover:bg-sky-50 xl:flex-col xl:justify-center">
52
+ <span class="text-sm font-medium text-slate-700 xl:sr-only"><%= action[:display_label] %></span>
53
+ <%= render "toggle", action: action %>
54
+ </div>
55
+ <% else %>
56
+ <span class="hidden text-slate-300 xl:inline" aria-label="<%= t("lesli_shield.roles.permissions_not_available") %>">—</span>
57
+ <% end %>
58
+ </td>
59
+ <% end %>
60
+ </tr>
61
+ <% end %>
62
+ </tbody>
63
+ </table>
64
+ <% end %>
65
+ <% if custom_resources.any? %>
66
+ <%= render "custom_actions", resources: custom_resources %>
67
+ <% end %>
68
+ </section>
69
+ <% end %>