lesli_shield 1.0.3 → 1.0.4

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 (111) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/stylesheets/lesli_shield/confirmations.css +18732 -0
  3. data/app/assets/stylesheets/lesli_shield/passwords.css +2 -238
  4. data/app/assets/stylesheets/lesli_shield/registrations.css +2 -238
  5. data/app/assets/stylesheets/lesli_shield/sessions.css +2 -238
  6. data/app/controllers/lesli_shield/dashboards_controller.rb +1 -8
  7. data/app/controllers/lesli_shield/invites_controller.rb +80 -0
  8. data/app/controllers/lesli_shield/role/actions_controller.rb +32 -20
  9. data/app/controllers/lesli_shield/roles_controller.rb +16 -8
  10. data/app/controllers/lesli_shield/sessions_controller.rb +5 -8
  11. data/app/controllers/lesli_shield/user/roles_controller.rb +62 -0
  12. data/app/controllers/lesli_shield/users_controller.rb +57 -20
  13. data/app/controllers/users/confirmations_controller.rb +42 -8
  14. data/app/controllers/users/passwords_controller.rb +52 -37
  15. data/app/controllers/users/registrations_controller.rb +2 -8
  16. data/app/controllers/users/sessions_controller.rb +57 -50
  17. data/app/helpers/lesli_shield/invites_helper.rb +4 -0
  18. data/app/helpers/lesli_shield/user/roles_helper.rb +4 -0
  19. data/app/interfaces/lesli_shield/authorization_interface.rb +8 -2
  20. data/app/mailers/lesli_shield/devise_mailer.rb +98 -0
  21. data/app/mailers/lesli_shield/invitation.html.erb +23 -0
  22. data/app/models/concerns/lesli_shield/user_security.rb +222 -0
  23. data/app/models/lesli_shield/account.rb +1 -1
  24. data/app/models/lesli_shield/dashboard.rb +1 -4
  25. data/app/models/lesli_shield/invite.rb +24 -0
  26. data/{lib/vue/confirmations.js → app/models/lesli_shield/role/action.rb} +17 -10
  27. data/{db/migrate/v1/0801003010_create_lesli_shield_dashboards.rb → app/models/lesli_shield/role/privilege.rb} +5 -4
  28. data/app/models/lesli_shield/user/role.rb +8 -0
  29. data/app/models/lesli_shield/user/session.rb +80 -0
  30. data/app/services/lesli_shield/invite_service.rb +43 -0
  31. data/app/services/lesli_shield/role_action_service.rb +118 -0
  32. data/app/services/lesli_shield/role_privilege_service.rb +112 -0
  33. data/app/{operators/lesli_shield/user_registration_operator.rb → services/lesli_shield/user_registration_service.rb} +26 -29
  34. data/app/services/lesli_shield/user_session_service.rb +78 -0
  35. data/app/services/lesli_shield/user_validator_service.rb +221 -0
  36. data/app/views/devise/confirmations/show.html.erb +4 -6
  37. data/app/views/devise/passwords/edit.html.erb +1 -2
  38. data/app/views/devise/passwords/new.html.erb +1 -1
  39. data/app/views/devise/registrations/new.html.erb +5 -4
  40. data/app/views/devise/sessions/new.html.erb +3 -2
  41. data/app/views/devise/shared/_application-devise-simple.erb +59 -0
  42. data/app/views/devise/shared/_application-devise.html.erb +76 -0
  43. data/app/views/lesli_shield/dashboards/_component-calendar.html.erb +1 -0
  44. data/app/views/lesli_shield/dashboards/_component-chart-bar.html.erb +6 -0
  45. data/app/views/lesli_shield/dashboards/_component-chart-line.html.erb +8 -0
  46. data/app/views/lesli_shield/dashboards/_component-count.html.erb +1 -0
  47. data/app/views/lesli_shield/dashboards/_component-date.html.erb +1 -0
  48. data/app/views/lesli_shield/dashboards/_component-weather.html.erb +1 -0
  49. data/app/views/lesli_shield/invites/_form.html.erb +10 -0
  50. data/app/views/lesli_shield/invites/_invite.html.erb +2 -0
  51. data/app/views/lesli_shield/invites/edit.html.erb +12 -0
  52. data/app/views/lesli_shield/invites/index.html.erb +66 -0
  53. data/{db/migrate/v1/0801001710_create_lesli_shield_settings.rb → app/views/lesli_shield/invites/new.html.erb} +9 -10
  54. data/{lib/vue/apps/dashboards/components/engine-version.vue → app/views/lesli_shield/invites/show.html.erb} +26 -43
  55. data/app/views/lesli_shield/partials/_navigation.html.erb +2 -4
  56. data/app/views/lesli_shield/{roles/_form-privileges.html.erb → role/actions/_form.html.erb} +5 -30
  57. data/app/views/lesli_shield/role/actions/index.html.erb +14 -0
  58. data/app/views/lesli_shield/roles/index.html.erb +2 -6
  59. data/app/views/lesli_shield/roles/new.html.erb +0 -11
  60. data/app/views/lesli_shield/roles/show.html.erb +5 -8
  61. data/app/views/lesli_shield/user/roles/_form.html.erb +17 -0
  62. data/app/views/lesli_shield/user/roles/_role.html.erb +2 -0
  63. data/app/views/lesli_shield/user/roles/edit.html.erb +12 -0
  64. data/app/views/lesli_shield/user/roles/index.html.erb +16 -0
  65. data/app/views/lesli_shield/user/roles/new.html.erb +11 -0
  66. data/app/views/lesli_shield/user/roles/show.html.erb +10 -0
  67. data/app/views/lesli_shield/users/{_viewer-activities.html.erb → _activities-viewer.html.erb} +2 -4
  68. data/app/views/lesli_shield/users/_information-card.html.erb +3 -3
  69. data/app/views/lesli_shield/users/_management-privileges.html.erb +74 -0
  70. data/app/views/lesli_shield/users/_management-security.html.erb +5 -0
  71. data/app/views/lesli_shield/users/index.html.erb +3 -7
  72. data/app/views/lesli_shield/users/new.html.erb +5 -11
  73. data/app/views/lesli_shield/users/show.html.erb +7 -5
  74. data/config/initializers/devise.rb +305 -304
  75. data/config/locales/translations.en.yml +4 -1
  76. data/config/locales/translations.es.yml +4 -1
  77. data/config/locales/translations.it.yml +4 -1
  78. data/config/routes.rb +7 -8
  79. data/db/migrate/v1/0801100210_create_lesli_shield_role_actions.rb +48 -0
  80. data/db/migrate/v1/0801100410_create_lesli_shield_role_privileges.rb +45 -0
  81. data/db/migrate/v1/0801110110_create_lesli_shield_user_roles.rb +43 -0
  82. data/db/migrate/v1/0801111210_create_lesli_shield_user_sessions.rb +56 -0
  83. data/db/migrate/v1/0801120110_create_lesli_shield_invites.rb +49 -0
  84. data/lib/lesli_shield/router.rb +21 -0
  85. data/lib/lesli_shield/version.rb +2 -2
  86. data/lib/lesli_shield.rb +1 -1
  87. data/lib/scss/confirmations.scss +24 -24
  88. data/lib/tasks/lesli_shield_tasks.rake +1 -1
  89. data/readme.md +59 -20
  90. metadata +57 -33
  91. data/app/controllers/lesli_shield/dashboard/components_controller.rb +0 -60
  92. data/app/models/lesli_shield/dashboard/component.rb +0 -18
  93. data/app/views/lesli_shield/dashboards/edit.html.erb +0 -1
  94. data/app/views/lesli_shield/dashboards/index.html.erb +0 -9
  95. data/app/views/lesli_shield/dashboards/new.html.erb +0 -1
  96. data/app/views/lesli_shield/dashboards/show.html.erb +0 -1
  97. data/app/views/lesli_shield/roles/_session.html.erb +0 -2
  98. data/app/views/lesli_shield/roles/edit.html.erb +0 -12
  99. data/app/views/lesli_shield/roles/update.turbo_stream.erb +0 -3
  100. data/app/views/lesli_shield/users/update.turbo_stream.erb +0 -3
  101. data/lib/lesli_shield/routing.rb +0 -23
  102. data/lib/vue/application.js +0 -83
  103. data/lib/vue/apps/sessions/index.vue +0 -50
  104. data/lib/vue/passwords.js +0 -137
  105. data/lib/vue/registrations.js +0 -144
  106. data/lib/vue/sessions.js +0 -148
  107. data/lib/vue/stores/sessions.js +0 -43
  108. data/lib/vue/stores/translations.json +0 -162
  109. /data/app/views/lesli_shield/roles/{_form-information.html.erb → _form.html.erb} +0 -0
  110. /data/db/migrate/v1/{0801120310_create_lesli_shield_user_shortcuts.rb → 0801111010_create_lesli_shield_user_shortcuts.rb} +0 -0
  111. /data/db/migrate/v1/{0801120410_create_lesli_shield_user_tokens.rb → 0801111110_create_lesli_shield_user_tokens.rb} +0 -0
@@ -1086,7 +1086,7 @@ table th {
1086
1086
  width: 0.625em;
1087
1087
  }
1088
1088
 
1089
- .level:not(:last-child), .fixed-grid:not(:last-child), .grid:not(:last-child), .field:not(:last-child), .file:not(:last-child), .pagination:not(:last-child), .tabs:not(:last-child), .notification:not(:last-child), .buttons:not(:last-child), .table:not(:last-child), .table-container:not(:last-child), .tags:not(:last-child), .box:not(:last-child) {
1089
+ .level:not(:last-child), .fixed-grid:not(:last-child), .grid:not(:last-child), .field:not(:last-child), .file:not(:last-child), .pagination:not(:last-child), .tabs:not(:last-child), .notification:not(:last-child), .buttons:not(:last-child), .table:not(:last-child), .table-container:not(:last-child), .box:not(:last-child) {
1090
1090
  margin-bottom: var(--bulma-block-spacing);
1091
1091
  }
1092
1092
 
@@ -1742,242 +1742,6 @@ a.box:active {
1742
1742
  box-shadow: var(--bulma-box-link-active-shadow);
1743
1743
  }
1744
1744
 
1745
- /* Bulma Utilities */
1746
- .tags {
1747
- align-items: center;
1748
- color: hsl(var(--bulma-tag-h), var(--bulma-tag-s), var(--bulma-tag-color-l));
1749
- display: flex;
1750
- flex-wrap: wrap;
1751
- gap: 0.5rem;
1752
- justify-content: flex-start;
1753
- }
1754
- .tags.are-medium .tag:not(.is-normal):not(.is-large) {
1755
- font-size: var(--bulma-size-normal);
1756
- }
1757
- .tags.are-large .tag:not(.is-normal):not(.is-medium) {
1758
- font-size: var(--bulma-size-medium);
1759
- }
1760
- .tags.is-centered {
1761
- gap: 0.25rem;
1762
- justify-content: center;
1763
- }
1764
- .tags.is-right {
1765
- justify-content: flex-end;
1766
- }
1767
- .tags.has-addons {
1768
- gap: 0;
1769
- }
1770
- .tags.has-addons .tag:not(:first-child) {
1771
- border-start-start-radius: 0;
1772
- border-end-start-radius: 0;
1773
- }
1774
- .tags.has-addons .tag:not(:last-child) {
1775
- border-start-end-radius: 0;
1776
- border-end-end-radius: 0;
1777
- }
1778
-
1779
- .tag {
1780
- --bulma-tag-h: var(--bulma-scheme-h);
1781
- --bulma-tag-s: var(--bulma-scheme-s);
1782
- --bulma-tag-background-l: var(--bulma-background-l);
1783
- --bulma-tag-background-l-delta: 0%;
1784
- --bulma-tag-hover-background-l-delta: var(--bulma-hover-background-l-delta);
1785
- --bulma-tag-active-background-l-delta: var(--bulma-active-background-l-delta);
1786
- --bulma-tag-color-l: var(--bulma-text-l);
1787
- --bulma-tag-radius: var(--bulma-radius);
1788
- --bulma-tag-delete-margin: 1px;
1789
- align-items: center;
1790
- background-color: hsl(var(--bulma-tag-h), var(--bulma-tag-s), calc(var(--bulma-tag-background-l) + var(--bulma-tag-background-l-delta)));
1791
- border-radius: var(--bulma-radius);
1792
- color: hsl(var(--bulma-tag-h), var(--bulma-tag-s), var(--bulma-tag-color-l));
1793
- display: inline-flex;
1794
- font-size: var(--bulma-size-small);
1795
- height: 2em;
1796
- justify-content: center;
1797
- line-height: 1.5;
1798
- padding-left: 0.75em;
1799
- padding-right: 0.75em;
1800
- white-space: nowrap;
1801
- }
1802
- .tag .delete {
1803
- margin-inline-start: 0.25rem;
1804
- margin-inline-end: -0.375rem;
1805
- }
1806
- .tag.is-white {
1807
- --bulma-tag-h: var(--bulma-white-h);
1808
- --bulma-tag-s: var(--bulma-white-s);
1809
- --bulma-tag-background-l: var(--bulma-white-l);
1810
- --bulma-tag-color-l: var(--bulma-white-invert-l);
1811
- }
1812
- .tag.is-white.is-light {
1813
- --bulma-tag-background-l: var(--bulma-light-l);
1814
- --bulma-tag-color-l: var(--bulma-white-light-invert-l);
1815
- }
1816
- .tag.is-black {
1817
- --bulma-tag-h: var(--bulma-black-h);
1818
- --bulma-tag-s: var(--bulma-black-s);
1819
- --bulma-tag-background-l: var(--bulma-black-l);
1820
- --bulma-tag-color-l: var(--bulma-black-invert-l);
1821
- }
1822
- .tag.is-black.is-light {
1823
- --bulma-tag-background-l: var(--bulma-light-l);
1824
- --bulma-tag-color-l: var(--bulma-black-light-invert-l);
1825
- }
1826
- .tag.is-light {
1827
- --bulma-tag-h: var(--bulma-light-h);
1828
- --bulma-tag-s: var(--bulma-light-s);
1829
- --bulma-tag-background-l: var(--bulma-light-l);
1830
- --bulma-tag-color-l: var(--bulma-light-invert-l);
1831
- }
1832
- .tag.is-light.is-light {
1833
- --bulma-tag-background-l: var(--bulma-light-l);
1834
- --bulma-tag-color-l: var(--bulma-light-light-invert-l);
1835
- }
1836
- .tag.is-dark {
1837
- --bulma-tag-h: var(--bulma-dark-h);
1838
- --bulma-tag-s: var(--bulma-dark-s);
1839
- --bulma-tag-background-l: var(--bulma-dark-l);
1840
- --bulma-tag-color-l: var(--bulma-dark-invert-l);
1841
- }
1842
- .tag.is-dark.is-light {
1843
- --bulma-tag-background-l: var(--bulma-light-l);
1844
- --bulma-tag-color-l: var(--bulma-dark-light-invert-l);
1845
- }
1846
- .tag.is-text {
1847
- --bulma-tag-h: var(--bulma-text-h);
1848
- --bulma-tag-s: var(--bulma-text-s);
1849
- --bulma-tag-background-l: var(--bulma-text-l);
1850
- --bulma-tag-color-l: var(--bulma-text-invert-l);
1851
- }
1852
- .tag.is-text.is-light {
1853
- --bulma-tag-background-l: var(--bulma-light-l);
1854
- --bulma-tag-color-l: var(--bulma-text-light-invert-l);
1855
- }
1856
- .tag.is-primary {
1857
- --bulma-tag-h: var(--bulma-primary-h);
1858
- --bulma-tag-s: var(--bulma-primary-s);
1859
- --bulma-tag-background-l: var(--bulma-primary-l);
1860
- --bulma-tag-color-l: var(--bulma-primary-invert-l);
1861
- }
1862
- .tag.is-primary.is-light {
1863
- --bulma-tag-background-l: var(--bulma-light-l);
1864
- --bulma-tag-color-l: var(--bulma-primary-light-invert-l);
1865
- }
1866
- .tag.is-link {
1867
- --bulma-tag-h: var(--bulma-link-h);
1868
- --bulma-tag-s: var(--bulma-link-s);
1869
- --bulma-tag-background-l: var(--bulma-link-l);
1870
- --bulma-tag-color-l: var(--bulma-link-invert-l);
1871
- }
1872
- .tag.is-link.is-light {
1873
- --bulma-tag-background-l: var(--bulma-light-l);
1874
- --bulma-tag-color-l: var(--bulma-link-light-invert-l);
1875
- }
1876
- .tag.is-info {
1877
- --bulma-tag-h: var(--bulma-info-h);
1878
- --bulma-tag-s: var(--bulma-info-s);
1879
- --bulma-tag-background-l: var(--bulma-info-l);
1880
- --bulma-tag-color-l: var(--bulma-info-invert-l);
1881
- }
1882
- .tag.is-info.is-light {
1883
- --bulma-tag-background-l: var(--bulma-light-l);
1884
- --bulma-tag-color-l: var(--bulma-info-light-invert-l);
1885
- }
1886
- .tag.is-success {
1887
- --bulma-tag-h: var(--bulma-success-h);
1888
- --bulma-tag-s: var(--bulma-success-s);
1889
- --bulma-tag-background-l: var(--bulma-success-l);
1890
- --bulma-tag-color-l: var(--bulma-success-invert-l);
1891
- }
1892
- .tag.is-success.is-light {
1893
- --bulma-tag-background-l: var(--bulma-light-l);
1894
- --bulma-tag-color-l: var(--bulma-success-light-invert-l);
1895
- }
1896
- .tag.is-warning {
1897
- --bulma-tag-h: var(--bulma-warning-h);
1898
- --bulma-tag-s: var(--bulma-warning-s);
1899
- --bulma-tag-background-l: var(--bulma-warning-l);
1900
- --bulma-tag-color-l: var(--bulma-warning-invert-l);
1901
- }
1902
- .tag.is-warning.is-light {
1903
- --bulma-tag-background-l: var(--bulma-light-l);
1904
- --bulma-tag-color-l: var(--bulma-warning-light-invert-l);
1905
- }
1906
- .tag.is-danger {
1907
- --bulma-tag-h: var(--bulma-danger-h);
1908
- --bulma-tag-s: var(--bulma-danger-s);
1909
- --bulma-tag-background-l: var(--bulma-danger-l);
1910
- --bulma-tag-color-l: var(--bulma-danger-invert-l);
1911
- }
1912
- .tag.is-danger.is-light {
1913
- --bulma-tag-background-l: var(--bulma-light-l);
1914
- --bulma-tag-color-l: var(--bulma-danger-light-invert-l);
1915
- }
1916
- .tag.is-normal {
1917
- font-size: var(--bulma-size-small);
1918
- }
1919
- .tag.is-medium {
1920
- font-size: var(--bulma-size-normal);
1921
- }
1922
- .tag.is-large {
1923
- font-size: var(--bulma-size-medium);
1924
- }
1925
- .tag .icon:first-child:not(:last-child) {
1926
- margin-inline-start: -0.375em;
1927
- margin-inline-end: 0.1875em;
1928
- }
1929
- .tag .icon:last-child:not(:first-child) {
1930
- margin-inline-start: 0.1875em;
1931
- margin-inline-end: -0.375em;
1932
- }
1933
- .tag .icon:first-child:last-child {
1934
- margin-inline-start: -0.375em;
1935
- margin-inline-end: -0.375em;
1936
- }
1937
- .tag.is-delete {
1938
- margin-inline-start: var(--bulma-tag-delete-margin);
1939
- padding: 0;
1940
- position: relative;
1941
- width: 2em;
1942
- }
1943
- .tag.is-delete::before, .tag.is-delete::after {
1944
- background-color: currentColor;
1945
- content: "";
1946
- display: block;
1947
- left: 50%;
1948
- position: absolute;
1949
- top: 50%;
1950
- transform: translateX(-50%) translateY(-50%) rotate(45deg);
1951
- transform-origin: center center;
1952
- }
1953
- .tag.is-delete::before {
1954
- height: 1px;
1955
- width: 50%;
1956
- }
1957
- .tag.is-delete::after {
1958
- height: 50%;
1959
- width: 1px;
1960
- }
1961
- .tag.is-rounded {
1962
- border-radius: var(--bulma-radius-rounded);
1963
- }
1964
-
1965
- a.tag,
1966
- button.tag,
1967
- .tag.is-hoverable {
1968
- cursor: pointer;
1969
- }
1970
- a.tag:hover,
1971
- button.tag:hover,
1972
- .tag.is-hoverable:hover {
1973
- --bulma-tag-background-l-delta: var(--bulma-tag-hover-background-l-delta);
1974
- }
1975
- a.tag:active,
1976
- button.tag:active,
1977
- .tag.is-hoverable:active {
1978
- --bulma-tag-background-l-delta: var(--bulma-tag-active-background-l-delta);
1979
- }
1980
-
1981
1745
  /* Bulma Utilities */
1982
1746
  .icon,
1983
1747
  .icon-text {
@@ -18671,7 +18435,7 @@ Building a better future, one line of code at a time.
18671
18435
  */
18672
18436
  :root {
18673
18437
  --lesli-color-primary: var(--lesli-theme-color-primary, #193d8d);
18674
- --lesli-color-background: var(--lesli-theme-color-background, #f8f4f4);
18438
+ --lesli-color-background: var(--lesli-theme-color-background, #f9f5f3);
18675
18439
  --lesli-header-color: var(--lesli-theme-header-color, white);
18676
18440
  --lesli-header-height: var(--lesli-theme-header-height, 65px);
18677
18441
  --lesli-footer-color: var(--lesli-theme-footer-color, white);
@@ -1,11 +1,4 @@
1
1
  module LesliShield
2
- class DashboardsController < ApplicationController
3
- before_action :set_session, only: %i[ ]
4
-
5
- def index
6
- end
7
-
8
- def show
9
- end
2
+ class DashboardsController < Lesli::Shared::DashboardsController
10
3
  end
11
4
  end
@@ -0,0 +1,80 @@
1
+ module LesliShield
2
+ class InvitesController < ApplicationController
3
+ before_action :set_invite, only: %i[ show edit update destroy ]
4
+
5
+ # GET /invites
6
+ def index
7
+ @invites = respond_with_pagination(LesliShield::InviteService.new(current_user, query).index(params))
8
+ end
9
+
10
+ # GET /invites/1
11
+ def show
12
+ end
13
+
14
+ # GET /invites/new
15
+ def new
16
+ @invite = Invite.new
17
+ end
18
+
19
+ # GET /invites/1/edit
20
+ def edit
21
+ end
22
+
23
+ # POST /invites
24
+ def create
25
+ @invite = current_user.account.shield.invites.new(invite_params)
26
+ @invite.user = current_user
27
+ if @invite.save
28
+
29
+ log(
30
+ subject: @invite,
31
+ operation: 'invite.created',
32
+ description: "Invitation created successfully created for: #{@invite.email}"
33
+ )
34
+
35
+ success("Invite was successfully created.")
36
+ respond_with_lesli(
37
+ turbo: stream_redirection(invite_path(@invite))
38
+ )
39
+ else
40
+ respond_with_lesli(
41
+ turbo: stream_notification_danger(@invite.errors.full_messages.to_sentence)
42
+ )
43
+ end
44
+ end
45
+
46
+ # PATCH/PUT /invites/1
47
+ def update
48
+ if @invite.update(invite_params)
49
+ log(
50
+ subject: @invite,
51
+ description: "Invitation updated successfully"
52
+ )
53
+ respond_with_lesli(
54
+ :turbo => stream_notification_success("Invite was successfully updated.")
55
+ )
56
+ else
57
+ respond_with_lesli(
58
+ :turbo => stream_notification_danger(@invite.errors.full_messages.to_sentence)
59
+ )
60
+ end
61
+ end
62
+
63
+ # DELETE /invites/1
64
+ def destroy
65
+ @invite.destroy!
66
+ redirect_to invites_path, notice: "Invite was successfully destroyed.", status: :see_other
67
+ end
68
+
69
+ private
70
+ # Use callbacks to share common setup or constraints between actions.
71
+ def set_invite
72
+ @invite = Invite.find(params.expect(:id))
73
+ end
74
+
75
+ # Only allow a list of trusted parameters through.
76
+ def invite_params
77
+ params.require(:invite).permit(:email, :full_name, :telephone, :notes, :status)
78
+ end
79
+ end
80
+ end
@@ -1,40 +1,52 @@
1
1
  module LesliShield
2
2
  class Role::ActionsController < ApplicationController
3
- before_action :set_role_action, only: %i[update destroy ]
3
+ before_action :set_role, only: %i[index update destroy]
4
+ before_action :set_role_action, only: %i[update destroy]
5
+
6
+ def index
7
+ @role_actions = RoleActionService.new(current_user, query).index(@role.id)
8
+ end
4
9
 
5
10
  def update
6
- # check saved
7
11
  if @role_action.result.recover
8
- success("Role privileges added successfully!")
9
- respond_to do |format|
10
- format.turbo_stream
11
- render turbo_stream: turbo_stream.replace("application-lesli-notifications", partial: "lesli/partials/application-lesli-notifications")
12
- #format.html { redirect_to role_path(@role_action.role_id) }
13
- end
12
+ @role_actions = RoleActionService.new(current_user, query).index(@role.id)
13
+ respond_with_lesli(
14
+ :turbo => [
15
+ stream_notification_success("Role privileges added successfully!"),
16
+ turbo_stream.replace('shield-role-actions-form', partial: 'lesli_shield/role/actions/form')
17
+ ]
18
+ )
14
19
  else
15
- respond_with_error(@user.errors)
20
+ respond_with_lesli(
21
+ :turbo => stream_notification_danger(@role_action.errors_as_sentence)
22
+ )
16
23
  end
17
24
  end
18
25
 
19
26
  def destroy
20
- # check saved
21
- if @role_action.result.destroy
22
- # success("Role privileges removed successfully!")
23
- # respond_to do |format|
24
- # format.turbo_stream
25
- # #format.html { redirect_to role_path(@role_action.role_id) }
26
- # end
27
- return true
27
+ if @role_action.result.delete
28
+ @role_actions = RoleActionService.new(current_user, query).index(@role.id)
29
+ respond_with_lesli(
30
+ :turbo => [
31
+ stream_notification_warning("Role privileges removed successfully!"),
32
+ turbo_stream.replace('shield-role-actions-form', partial: 'lesli_shield/role/actions/form')
33
+ ]
34
+ )
28
35
  else
29
- respond_with_error(@user.errors)
36
+ respond_with_lesli(
37
+ :turbo => stream_notification_danger(@role_action.errors_as_sentence)
38
+ )
30
39
  end
31
40
  end
32
41
 
33
42
  private
34
43
 
35
- # Use callbacks to share common setup or constraints between actions.
44
+ def set_role
45
+ @role = current_user.account.roles.find(params[:role_id])
46
+ end
47
+
36
48
  def set_role_action
37
- @role_action = Lesli::Role::ActionService.new(current_user).find(params[:id])
49
+ @role_action = RoleActionService.new(current_user).find(params[:id])
38
50
  end
39
51
 
40
52
  def role_action_params
@@ -34,13 +34,25 @@ module LesliShield
34
34
  class RolesController < ApplicationController
35
35
  before_action :set_role, only: %i[ show update destroy ]
36
36
 
37
+ def deploy
38
+ pp params[:id]
39
+ pp params[:id]
40
+ pp params[:id]
41
+ pp params[:id]
42
+
43
+ RolePrivilegeService.new.synchronize(Lesli::Role.first)
44
+
45
+ respond_with_lesli(
46
+ :turbo => stream_notification_success("success")
47
+ )
48
+ end
49
+
37
50
  def index
38
- @roles = respond_as_pagination(Lesli::RoleService.new(current_user, query).index)
51
+ @roles = respond_with_pagination(Lesli::RoleService.new(current_user, query).index)
39
52
  end
40
53
 
41
54
  def show
42
55
  @role = @role.show
43
- @role_actions = Lesli::Role::ActionService.new(current_user, query).index(@role.id)
44
56
  end
45
57
 
46
58
  # @return [HTML] HTML view for creating a new role
@@ -100,13 +112,9 @@ module LesliShield
100
112
 
101
113
  # check if the update went OK
102
114
  if @role.successful?
103
- success("Role updated successfully!")
104
- respond_to do |format|
105
- format.turbo_stream
106
- format.html { redirect_to @role }
107
- end
115
+ respond_with_lesli(:turbo => stream_notification_success("Role updated successfully!"))
108
116
  else
109
- respond_with_error(@role.errors)
117
+ respond_with_lesli(:turbo => stream_notification_danger(@role.errors_as_sentence))
110
118
  end
111
119
  end
112
120
 
@@ -4,14 +4,11 @@ module LesliShield
4
4
 
5
5
  # GET /sessions
6
6
  def index
7
- respond_to do |format|
8
- format.html {
9
- @sessions = respond_as_pagination(Lesli::User::SessionService.new(current_user, query).index())
10
- }
11
- format.json {
12
- respond_with_pagination(UserSessionService.new(current_user, query).index())
13
- }
14
- end
7
+ @sessions = respond_with_pagination(UserSessionService.new(current_user, query).index())
8
+ respond_with_lesli(
9
+ :html => @sessions,
10
+ :json => @sessions
11
+ )
15
12
  end
16
13
 
17
14
  # GET /sessions/1
@@ -0,0 +1,62 @@
1
+ module LesliShield
2
+ class User::RolesController < ApplicationController
3
+ before_action :set_user_role, only: %i[ show edit update destroy ]
4
+
5
+ # GET /user/roles
6
+ def index
7
+ @user_roles = User::Role.all
8
+ end
9
+
10
+ # GET /user/roles/1
11
+ def show
12
+ end
13
+
14
+ # GET /user/roles/new
15
+ def new
16
+ @user_role = User::Role.new
17
+ end
18
+
19
+ # GET /user/roles/1/edit
20
+ def edit
21
+ end
22
+
23
+ # POST /user/roles
24
+ def create
25
+ # @user_role = User::Role.new(user_role_params)
26
+
27
+ # if @user_role.save
28
+ # redirect_to @user_role, notice: "Role was successfully created."
29
+ # else
30
+ # render :new, status: :unprocessable_content
31
+ # end
32
+ end
33
+
34
+ # PATCH/PUT /user/roles/1
35
+ def update
36
+ # if @user_role.update(user_role_params)
37
+ # redirect_to @user_role, notice: "Role was successfully updated.", status: :see_other
38
+ # else
39
+ # render :edit, status: :unprocessable_content
40
+ # end
41
+ end
42
+
43
+ # DELETE /user/roles/1
44
+ def destroy
45
+ @user_role.destroy!
46
+ redirect_to user_roles_path, notice: "Role was successfully destroyed.", status: :see_other
47
+ end
48
+
49
+ private
50
+ # Use callbacks to share common setup or constraints between actions.
51
+ def set_user_role
52
+ @user_role = User::Role.find(params.expect(:id))
53
+ end
54
+
55
+ # Only allow a list of trusted parameters through.
56
+ def user_role_params
57
+ params.require(:user_role).permit(
58
+ :role_id
59
+ )
60
+ end
61
+ end
62
+ end
@@ -1,20 +1,52 @@
1
+ =begin
2
+
3
+ Lesli
4
+
5
+ Copyright (c) 2026, 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 LesliTech
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
+ =end
32
+
1
33
  module LesliShield
2
34
  class UsersController < ApplicationController
3
35
  before_action :set_user, only: %i[ show edit update destroy ]
4
36
 
5
37
  # GET /users
6
38
  def index
7
- @users = respond_as_pagination(Lesli::UserService.new(current_user, query).index(params))
39
+ @users = respond_with_pagination(Lesli::UserService.new(current_user, query).index(params))
8
40
  end
9
41
 
10
42
  # GET /users/1
11
43
  def show
12
- @activities = @user.result.activities.order(id: :desc).map { |a| {
13
- id: a[:id],
14
- title: a[:title].titleize,
15
- description: a[:description],
16
- date: Date2.new(a[:created_at]).date_words
17
- }}
44
+ @user_roles = @user.result.roles
45
+ @activities = @user.result.logs
46
+ .order(id: :desc)
47
+ .select(:id, :operation, :description, Date2.new.db_column('created_at', as:'date'))
48
+ .limit(7)
49
+ .as_json
18
50
  @sessions = @user.result.sessions
19
51
  @user = @user.show
20
52
  end
@@ -33,44 +65,49 @@ module LesliShield
33
65
  @user = User.new(user_params)
34
66
 
35
67
  if @user.save
36
- redirect_to @user, notice: "User was successfully created."
68
+ respond_with_stream(
69
+ stream_notification_success('User was successfully created.')
70
+ )
37
71
  else
38
- render :new, status: :unprocessable_entity
72
+ respond_with_stream(
73
+ stream_notification_danger(@user.errors.full_messages.to_sentence)
74
+ )
39
75
  end
40
76
  end
41
77
 
42
78
  # PATCH/PUT /users/1
43
79
  def update
44
80
 
45
- # check if the user trully exists
46
- return respond_with_not_found unless @user.found?
47
-
48
81
  # update the user information
49
82
  @user.update(user_params)
50
83
 
51
84
  # check saved
52
85
  if @user.successful?
53
- success("User updated successfully!")
54
- respond_to do |format|
55
- format.turbo_stream
56
- format.html { redirect_to @user }
57
- end
86
+ respond_with_lesli(
87
+ :turbo => stream_notification_success("User updated successfully!")
88
+ )
58
89
  else
59
- respond_with_error(@user.errors)
90
+ respond_with_lesli(
91
+ :turbo => stream_notification_danger(@user.errors_as_sentence)
92
+ )
60
93
  end
61
94
  end
62
95
 
63
96
  # DELETE /users/1
64
97
  def destroy
65
98
  @user.destroy!
66
- redirect_to users_path, notice: "User was successfully destroyed.", status: :see_other
99
+ redirect_to(users_path, notice: "User was successfully destroyed.", status: :see_other)
67
100
  end
68
101
 
69
102
  private
70
103
 
71
- # Use callbacks to share common setup or constraints between actions.
72
104
  def set_user
105
+
106
+ # Search for the user
73
107
  @user = Lesli::UserService.new(current_user).find(params[:id])
108
+
109
+ # check if the user trully exists
110
+ return respond_with_not_found unless @user.found?
74
111
  end
75
112
 
76
113
  # Only allow a list of trusted parameters through.