lesli_security 0.3.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.
Files changed (153) hide show
  1. checksums.yaml +7 -0
  2. data/Rakefile +38 -0
  3. data/app/assets/config/lesli_security_manifest.js +38 -0
  4. data/app/assets/images/lesli_security/security-logo.svg +57 -0
  5. data/app/assets/javascripts/lesli_security/application.js +5583 -0
  6. data/app/assets/stylesheets/lesli_security/application.css +95 -0
  7. data/app/controllers/lesli_security/accounts_controller.rb +60 -0
  8. data/app/controllers/lesli_security/application_controller.rb +37 -0
  9. data/app/controllers/lesli_security/dashboard/components_controller.rb +60 -0
  10. data/app/controllers/lesli_security/dashboards_controller.rb +36 -0
  11. data/app/controllers/lesli_security/descriptor/activities_controller.rb +122 -0
  12. data/app/controllers/lesli_security/descriptor/privileges_controller.rb +112 -0
  13. data/app/controllers/lesli_security/descriptors_controller.rb +129 -0
  14. data/app/controllers/lesli_security/role/activities_controller.rb +76 -0
  15. data/app/controllers/lesli_security/role/descriptors_controller.rb +97 -0
  16. data/app/controllers/lesli_security/role/privileges_controller.rb +47 -0
  17. data/app/controllers/lesli_security/roles_controller.rb +185 -0
  18. data/app/controllers/lesli_security/user/roles_controller.rb +98 -0
  19. data/app/controllers/lesli_security/user/sessions_controller.rb +71 -0
  20. data/app/controllers/lesli_security/users_controller.rb +206 -0
  21. data/app/helpers/lesli_security/accounts_helper.rb +4 -0
  22. data/app/helpers/lesli_security/application_helper.rb +4 -0
  23. data/app/helpers/lesli_security/dashboards_helper.rb +4 -0
  24. data/app/helpers/lesli_security/descriptor/activities_helper.rb +4 -0
  25. data/app/helpers/lesli_security/descriptor/privileges_helper.rb +4 -0
  26. data/app/helpers/lesli_security/descriptors_helper.rb +4 -0
  27. data/app/helpers/lesli_security/role/activities_helper.rb +4 -0
  28. data/app/helpers/lesli_security/role/descriptors_helper.rb +4 -0
  29. data/app/helpers/lesli_security/role/privileges_helper.rb +4 -0
  30. data/app/helpers/lesli_security/roles_helper.rb +4 -0
  31. data/app/jobs/lesli_security/application_job.rb +37 -0
  32. data/app/mailers/lesli_security/application_mailer.rb +39 -0
  33. data/app/models/lesli_security/account.rb +43 -0
  34. data/app/models/lesli_security/application_record.rb +37 -0
  35. data/app/models/lesli_security/dashboard/component.rb +42 -0
  36. data/app/models/lesli_security/dashboard.rb +58 -0
  37. data/app/models/lesli_security/descriptor/activity.rb +40 -0
  38. data/app/models/lesli_security/descriptor/privilege.rb +40 -0
  39. data/app/models/lesli_security/descriptor.rb +41 -0
  40. data/app/models/lesli_security/role/activity.rb +40 -0
  41. data/app/services/lesli_security/descriptor_privilege_service.rb +74 -0
  42. data/app/services/lesli_security/descriptor_service.rb +152 -0
  43. data/app/services/lesli_security/role_descriptor_service.rb +61 -0
  44. data/app/services/lesli_security/role_service.rb +215 -0
  45. data/app/services/lesli_security/user_service.rb +305 -0
  46. data/app/views/lesli_security/accounts/_account.html.erb +2 -0
  47. data/app/views/lesli_security/accounts/_form.html.erb +17 -0
  48. data/app/views/lesli_security/accounts/edit.html.erb +10 -0
  49. data/app/views/lesli_security/accounts/index.html.erb +14 -0
  50. data/app/views/lesli_security/accounts/new.html.erb +9 -0
  51. data/app/views/lesli_security/accounts/show.html.erb +10 -0
  52. data/app/views/lesli_security/dashboards/show.html.erb +1 -0
  53. data/app/views/lesli_security/descriptor/activities/_form.html.erb +32 -0
  54. data/app/views/lesli_security/descriptor/activities/edit.html.erb +34 -0
  55. data/app/views/lesli_security/descriptor/activities/index.html.erb +34 -0
  56. data/app/views/lesli_security/descriptor/activities/new.html.erb +34 -0
  57. data/app/views/lesli_security/descriptor/activities/show.html.erb +34 -0
  58. data/app/views/lesli_security/descriptor/privileges/_form.html.erb +32 -0
  59. data/app/views/lesli_security/descriptor/privileges/edit.html.erb +34 -0
  60. data/app/views/lesli_security/descriptor/privileges/index.html.erb +34 -0
  61. data/app/views/lesli_security/descriptor/privileges/new.html.erb +34 -0
  62. data/app/views/lesli_security/descriptor/privileges/show.html.erb +34 -0
  63. data/app/views/lesli_security/descriptors/_form.html.erb +32 -0
  64. data/app/views/lesli_security/descriptors/edit.html.erb +34 -0
  65. data/app/views/lesli_security/descriptors/index.html.erb +34 -0
  66. data/app/views/lesli_security/descriptors/new.html.erb +34 -0
  67. data/app/views/lesli_security/descriptors/show.html.erb +34 -0
  68. data/app/views/lesli_security/partials/_engine-navigation.html.erb +38 -0
  69. data/app/views/lesli_security/role/activities/_form.html.erb +32 -0
  70. data/app/views/lesli_security/role/activities/edit.html.erb +34 -0
  71. data/app/views/lesli_security/role/activities/index.html.erb +34 -0
  72. data/app/views/lesli_security/role/activities/new.html.erb +34 -0
  73. data/app/views/lesli_security/role/activities/show.html.erb +34 -0
  74. data/app/views/lesli_security/role/descriptors/_form.html.erb +32 -0
  75. data/app/views/lesli_security/role/descriptors/edit.html.erb +34 -0
  76. data/app/views/lesli_security/role/descriptors/index.html.erb +34 -0
  77. data/app/views/lesli_security/role/descriptors/new.html.erb +34 -0
  78. data/app/views/lesli_security/role/descriptors/show.html.erb +34 -0
  79. data/app/views/lesli_security/role/privileges/_form.html.erb +32 -0
  80. data/app/views/lesli_security/role/privileges/edit.html.erb +34 -0
  81. data/app/views/lesli_security/role/privileges/index.html.erb +34 -0
  82. data/app/views/lesli_security/role/privileges/new.html.erb +34 -0
  83. data/app/views/lesli_security/role/privileges/show.html.erb +34 -0
  84. data/app/views/lesli_security/roles/edit.html.erb +34 -0
  85. data/app/views/lesli_security/roles/index.html.erb +34 -0
  86. data/app/views/lesli_security/roles/new.html.erb +34 -0
  87. data/app/views/lesli_security/roles/show.html.erb +34 -0
  88. data/app/views/lesli_security/users/edit.html.erb +10 -0
  89. data/app/views/lesli_security/users/index.html.erb +34 -0
  90. data/app/views/lesli_security/users/new.html.erb +34 -0
  91. data/app/views/lesli_security/users/show.html.erb +1 -0
  92. data/config/locales/translations.en.yml +44 -0
  93. data/config/locales/translations.es.yml +44 -0
  94. data/config/locales/translations.fr.yml +44 -0
  95. data/config/locales/translations.it.yml +44 -0
  96. data/config/locales/translations.pt.yml +44 -0
  97. data/config/routes.rb +90 -0
  98. data/db/migrate/v1/0010000210_create_lesli_roles.rb +60 -0
  99. data/db/migrate/v1/0010000310_create_lesli_users.rb +97 -0
  100. data/db/migrate/v1/0010003010_create_lesli_user_details.rb +49 -0
  101. data/db/migrate/v1/0010003110_create_lesli_user_settings.rb +44 -0
  102. data/db/migrate/v1/0010003210_create_lesli_user_sessions.rb +55 -0
  103. data/db/migrate/v1/0010003410_create_lesli_user_powers.rb +43 -0
  104. data/db/migrate/v1/0010004010_create_lesli_user_logs.rb +45 -0
  105. data/db/migrate/v1/0010005010_create_lesli_descriptors.rb +44 -0
  106. data/db/migrate/v1/0010005110_create_lesli_descriptor_privileges.rb +45 -0
  107. data/db/migrate/v1/0010005210_create_lesli_descriptor_activities.rb +49 -0
  108. data/db/migrate/v1/0010005510_create_lesli_role_powers.rb +51 -0
  109. data/db/migrate/v1/0010005710_create_lesli_role_privileges.rb +45 -0
  110. data/db/migrate/v1/0802000110_create_lesli_security_accounts.rb +42 -0
  111. data/db/migrate/v1/0802050110_create_lesli_security_dashboards.rb +51 -0
  112. data/db/migrate/v1/0802050210_create_lesli_security_dashboard_components.rb +53 -0
  113. data/lib/lesli_security/engine.rb +18 -0
  114. data/lib/lesli_security/version.rb +4 -0
  115. data/lib/lesli_security.rb +6 -0
  116. data/lib/scss/application.scss +38 -0
  117. data/lib/scss/users.scss +67 -0
  118. data/lib/tasks/lesli_security_tasks.rake +50 -0
  119. data/lib/vue/application.js +112 -0
  120. data/lib/vue/apps/descriptors/components/form.vue +136 -0
  121. data/lib/vue/apps/descriptors/edit.vue +83 -0
  122. data/lib/vue/apps/descriptors/index.vue +113 -0
  123. data/lib/vue/apps/descriptors/new.vue +69 -0
  124. data/lib/vue/apps/descriptors/show.vue +233 -0
  125. data/lib/vue/apps/roles/components/descriptors.vue +81 -0
  126. data/lib/vue/apps/roles/components/form.vue +253 -0
  127. data/lib/vue/apps/roles/components/privilegeCustom.vue +86 -0
  128. data/lib/vue/apps/roles/components/privilegeStandard.vue +196 -0
  129. data/lib/vue/apps/roles/edit.vue +118 -0
  130. data/lib/vue/apps/roles/index.vue +168 -0
  131. data/lib/vue/apps/roles/logs.vue +110 -0
  132. data/lib/vue/apps/roles/new.vue +86 -0
  133. data/lib/vue/apps/roles/show.vue +109 -0
  134. data/lib/vue/apps/users/components/information-card.vue +104 -0
  135. data/lib/vue/apps/users/components/information-form.vue +176 -0
  136. data/lib/vue/apps/users/components/integrations-information.vue +61 -0
  137. data/lib/vue/apps/users/components/management-roles.vue +107 -0
  138. data/lib/vue/apps/users/components/management-security.vue +113 -0
  139. data/lib/vue/apps/users/components/management-sessions.vue +101 -0
  140. data/lib/vue/apps/users/components/management-settings.vue +93 -0
  141. data/lib/vue/apps/users/index.vue +207 -0
  142. data/lib/vue/apps/users/new.vue +181 -0
  143. data/lib/vue/apps/users/show.vue +131 -0
  144. data/lib/vue/stores/descriptor.js +117 -0
  145. data/lib/vue/stores/descriptors.js +156 -0
  146. data/lib/vue/stores/role.js +203 -0
  147. data/lib/vue/stores/roles.js +58 -0
  148. data/lib/vue/stores/translations.json +277 -0
  149. data/lib/vue/stores/user.js +331 -0
  150. data/lib/vue/stores/users.js +166 -0
  151. data/license +674 -0
  152. data/readme.md +76 -0
  153. metadata +225 -0
@@ -0,0 +1,95 @@
1
+ /*!************************************************************************************************************************************************************!*\
2
+ !*** css ./node_modules/css-loader/dist/cjs.js??clonedRuleSet-31.use[1]!./node_modules/sass-loader/dist/cjs.js!../LesliSecurity/lib/scss/application.scss ***!
3
+ \************************************************************************************************************************************************************/
4
+ @charset "UTF-8";
5
+ /*
6
+
7
+ Lesli
8
+
9
+ Copyright (c) 2023, Lesli Technologies, S. A.
10
+
11
+ This program is free software: you can redistribute it and/or modify
12
+ it under the terms of the GNU General Public License as published by
13
+ the Free Software Foundation, either version 3 of the License, or
14
+ (at your option) any later version.
15
+
16
+ This program is distributed in the hope that it will be useful,
17
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
18
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19
+ GNU General Public License for more details.
20
+
21
+ You should have received a copy of the GNU General Public License
22
+ along with this program. If not, see http://www.gnu.org/licenses/.
23
+
24
+ Lesli · Ruby on Rails SaaS Development Framework.
25
+
26
+ Made with ♥ by https://www.lesli.tech
27
+ Building a better future, one line of code at a time.
28
+
29
+ @contact hello@lesli.tech
30
+ @website https://www.lesli.tech
31
+ @license GPLv3 http://www.gnu.org/licenses/gpl-3.0.en.html
32
+
33
+ // · ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~
34
+ // ·
35
+ */
36
+ body.lesli-guard-users {
37
+ /*
38
+ Lesli
39
+
40
+ Copyright (c) 2023, Lesli Technologies, S. A.
41
+
42
+ This program is free software: you can redistribute it and/or modify
43
+ it under the terms of the GNU General Public License as published by
44
+ the Free Software Foundation, either version 3 of the License, or
45
+ (at your option) any later version.
46
+
47
+ This program is distributed in the hope that it will be useful,
48
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
49
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
50
+ GNU General Public License for more details.
51
+
52
+ You should have received a copy of the GNU General Public License
53
+ along with this program. If not, see http://www.gnu.org/licenses/.
54
+
55
+ Lesli · Ruby on Rails SaaS Development Framework.
56
+
57
+ Made with ♥ by https://www.lesli.tech
58
+ Building a better future, one line of code at a time.
59
+
60
+ @contact hello@lesli.tech
61
+ @website https://www.lesli.tech
62
+ @license GPLv3 http://www.gnu.org/licenses/gpl-3.0.en.html
63
+
64
+ // · ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~
65
+ // ·
66
+ */
67
+ }
68
+ body.lesli-guard-users .user-information-card figure {
69
+ display: flex;
70
+ align-items: center;
71
+ justify-content: center;
72
+ border-radius: 50%;
73
+ background-color: lesli-css-color(silver, 100);
74
+ border: 2px solid var(--lesli-color-primary, lesli-css-color(blue));
75
+ }
76
+ body.lesli-guard-users .user-information-card .alternative-avatar {
77
+ font-weight: 200;
78
+ font-size: 3rem;
79
+ color: var(--lesli-color-primary, lesli-css-color(blue));
80
+ }
81
+ body.lesli-guard-users form.information {
82
+ max-width: 80%;
83
+ }
84
+ body.lesli-guard-users .roles-types {
85
+ display: grid;
86
+ grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
87
+ grid-auto-rows: minmax(198px, auto);
88
+ gap: 20px;
89
+ }
90
+ body.lesli-guard-users .roles-types-item {
91
+ width: 100%;
92
+ height: 135px;
93
+ border-radius: 8px;
94
+ margin: 5px;
95
+ }
@@ -0,0 +1,60 @@
1
+ module LesliSecurity
2
+ class AccountsController < ApplicationController
3
+ before_action :set_account, only: %i[ show edit update destroy ]
4
+
5
+ # GET /accounts
6
+ def index
7
+ @accounts = Account.all
8
+ end
9
+
10
+ # GET /accounts/1
11
+ def show
12
+ end
13
+
14
+ # GET /accounts/new
15
+ def new
16
+ @account = Account.new
17
+ end
18
+
19
+ # GET /accounts/1/edit
20
+ def edit
21
+ end
22
+
23
+ # POST /accounts
24
+ def create
25
+ @account = Account.new(account_params)
26
+
27
+ if @account.save
28
+ redirect_to @account, notice: "Account was successfully created."
29
+ else
30
+ render :new, status: :unprocessable_entity
31
+ end
32
+ end
33
+
34
+ # PATCH/PUT /accounts/1
35
+ def update
36
+ if @account.update(account_params)
37
+ redirect_to @account, notice: "Account was successfully updated.", status: :see_other
38
+ else
39
+ render :edit, status: :unprocessable_entity
40
+ end
41
+ end
42
+
43
+ # DELETE /accounts/1
44
+ def destroy
45
+ @account.destroy
46
+ redirect_to accounts_url, notice: "Account 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_account
52
+ @account = Account.find(params[:id])
53
+ end
54
+
55
+ # Only allow a list of trusted parameters through.
56
+ def account_params
57
+ params.fetch(:account, {})
58
+ end
59
+ end
60
+ end
@@ -0,0 +1,37 @@
1
+ =begin
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 platform.
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
+ =end
33
+
34
+ module LesliSecurity
35
+ class ApplicationController < Lesli::ApplicationLesliController
36
+ end
37
+ end
@@ -0,0 +1,60 @@
1
+ module LesliSecurity
2
+ class Dashboard::ComponentsController < ApplicationController
3
+ before_action :set_dashboard_component, only: %i[ show edit update destroy ]
4
+
5
+ # GET /dashboard/components
6
+ def index
7
+ @dashboard_components = Dashboard::Component.all
8
+ end
9
+
10
+ # GET /dashboard/components/1
11
+ def show
12
+ end
13
+
14
+ # GET /dashboard/components/new
15
+ def new
16
+ @dashboard_component = Dashboard::Component.new
17
+ end
18
+
19
+ # GET /dashboard/components/1/edit
20
+ def edit
21
+ end
22
+
23
+ # POST /dashboard/components
24
+ def create
25
+ @dashboard_component = Dashboard::Component.new(dashboard_component_params)
26
+
27
+ if @dashboard_component.save
28
+ redirect_to @dashboard_component, notice: "Component was successfully created."
29
+ else
30
+ render :new, status: :unprocessable_entity
31
+ end
32
+ end
33
+
34
+ # PATCH/PUT /dashboard/components/1
35
+ def update
36
+ if @dashboard_component.update(dashboard_component_params)
37
+ redirect_to @dashboard_component, notice: "Component was successfully updated.", status: :see_other
38
+ else
39
+ render :edit, status: :unprocessable_entity
40
+ end
41
+ end
42
+
43
+ # DELETE /dashboard/components/1
44
+ def destroy
45
+ @dashboard_component.destroy
46
+ redirect_to dashboard_components_url, notice: "Component 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_dashboard_component
52
+ @dashboard_component = Dashboard::Component.find(params[:id])
53
+ end
54
+
55
+ # Only allow a list of trusted parameters through.
56
+ def dashboard_component_params
57
+ params.fetch(:dashboard_component, {})
58
+ end
59
+ end
60
+ end
@@ -0,0 +1,36 @@
1
+ =begin
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
+ =end
32
+
33
+ module LesliSecurity
34
+ class DashboardsController < Lesli::Shared::DashboardsController
35
+ end
36
+ end
@@ -0,0 +1,122 @@
1
+ =begin
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 platform.
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
+ =end
33
+
34
+ module LesliSecurity
35
+ class Descriptor::ActivitiesController < ApplicationController
36
+ before_action :set_descriptor_activity, only: %i[ show update destroy ]
37
+
38
+ # GET /descriptor/activities/list.json
39
+ def list
40
+ respond_to do |format|
41
+ format.html {}
42
+ format.json do
43
+ respond_with_successful(Descriptor::ActivityServices.new(current_user, query).list)
44
+ end
45
+ end
46
+ end
47
+
48
+ # GET /descriptor/activities
49
+ def index
50
+ respond_to do |format|
51
+ format.html {}
52
+ format.json do
53
+ respond_with_pagination(Descriptor::ActivityServices.new(current_user, query).index)
54
+ end
55
+ end
56
+ end
57
+
58
+ # GET /descriptor/activities/:id
59
+ def show
60
+ respond_to do |format|
61
+ format.html {}
62
+ format.json do
63
+ return respond_with_successful(@descriptor_activity.show)
64
+ end
65
+ end
66
+ end
67
+
68
+ # GET /descriptor/activities/new
69
+ def new
70
+ end
71
+
72
+ # GET /descriptor/activities/:id/edit
73
+ def edit
74
+ end
75
+
76
+ # POST /descriptor/activities
77
+ def create
78
+ descriptor_activity = Descriptor::ActivityServices.new(current_user, query).create(descriptor_activity_params)
79
+ if descriptor_activity.successful?
80
+ respond_with_successful(descriptor_activity.result)
81
+ else
82
+ respond_with_error(descriptor_activity.errors)
83
+ end
84
+ end
85
+
86
+ # PATCH/PUT /descriptor/activities/:id
87
+ def update
88
+ @descriptor_activity.update(descriptor_activity_params)
89
+
90
+ if @descriptor_activity.successful?
91
+ respond_with_successful(@descriptor_activity.result)
92
+ else
93
+ respond_with_error(@descriptor_activity.errors)
94
+ end
95
+ end
96
+
97
+ # DELETE /descriptor/activities/1
98
+ def destroy
99
+ return respond_with_not_found unless @descriptor_activity
100
+
101
+ if @descriptor_activity.destroy
102
+ respond_with_successful
103
+ else
104
+ respond_with_error(@descriptor_activity.errors.full_messages.to_sentence)
105
+ end
106
+ end
107
+
108
+ private
109
+
110
+ # Use callbacks to share common setup or constraints between actions.
111
+ def set_descriptor_activity
112
+ @descriptor_activity = Descriptor::ActivityServices.new(current_user, query).find(params[:id])
113
+ return respond_with_not_found unless @descriptor_activity.found?
114
+ end
115
+
116
+ # Only allow a list of trusted parameters through.
117
+ def descriptor_activity_params
118
+ params.require(:descriptor_activity).permit(:id, :name)
119
+ end
120
+
121
+ end
122
+ end
@@ -0,0 +1,112 @@
1
+ =begin
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
+ =end
32
+
33
+ module LesliSecurity
34
+ class Descriptor::PrivilegesController < ApplicationController
35
+ before_action :set_descriptor, only: %i[ create destroy ]
36
+ before_action :set_descriptor_privilege, only: %i[ destroy ]
37
+
38
+
39
+ # GET /descriptor/privileges
40
+ def index
41
+ respond_to do |format|
42
+ format.html {}
43
+ format.json do
44
+ respond_with_successful(DescriptorPrivilegeService.new(current_user, @query).index(params))
45
+ end
46
+ end
47
+ end
48
+
49
+ # POST /descriptor/privileges
50
+ def create
51
+
52
+ descriptor_privilege_status = false
53
+
54
+ # search for the privilege we want to add/update
55
+
56
+ # if the privilege does not exist, we are going to create the privilege
57
+ descriptor_privilege = @descriptor.privileges.with_deleted.find_by(
58
+ :action_id => descriptor_privilege_params[:action_id]
59
+ )
60
+
61
+ # if the privilege exist, we are going to update the privilege
62
+ if not descriptor_privilege
63
+ pp "if not descriptor_privilege"
64
+ descriptor_privilege = @descriptor.privileges.new(
65
+ :action_id => descriptor_privilege_params[:action_id]
66
+ )
67
+ descriptor_privilege_status = descriptor_privilege.save
68
+ elsif !descriptor_privilege.deleted?
69
+ pp "elsif !descriptor_privilege.deleted?"
70
+ descriptor_privilege_status = descriptor_privilege.delete
71
+ elsif descriptor_privilege.deleted?
72
+ pp "elsif descriptor_privilege.deleted?"
73
+ descriptor_privilege_status = descriptor_privilege.recover
74
+ end
75
+
76
+ if descriptor_privilege_status
77
+ #Role::Activity.log_create_descriptor(current_user, @role, role_descriptor)
78
+ respond_with_successful(descriptor_privilege)
79
+ else
80
+ respond_with_error(descriptor_privilege.errors.full_messages.to_sentence)
81
+ end
82
+ end
83
+
84
+ # DELETE /descriptor/privileges/1
85
+ def destroy
86
+ if @descriptor_privilege.destroy
87
+ respond_with_successful
88
+ else
89
+ respond_with_error(@descriptor_privilege.errors.full_messages.to_sentence)
90
+ end
91
+ end
92
+
93
+ private
94
+
95
+ # Use callbacks to share common setup or constraints between actions.
96
+ def set_descriptor
97
+ @descriptor = current_user.account.descriptors.find_by_id(params[:descriptor_id])
98
+ return respond_with_not_found if @descriptor.blank?
99
+ end
100
+
101
+ # Use callbacks to share common setup or constraints between actions.
102
+ def set_descriptor_privilege
103
+ @descriptor_privilege = @descriptor.privileges.find_by(action_id: params[:id])
104
+ return respond_with_not_found if @descriptor_privilege.blank?
105
+ end
106
+
107
+ # Only allow a list of trusted parameters through.
108
+ def descriptor_privilege_params
109
+ params.require(:descriptor_privilege).permit(:id, :name, :action_id)
110
+ end
111
+ end
112
+ end
@@ -0,0 +1,129 @@
1
+ =begin
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
+ =end
32
+
33
+ module LesliSecurity
34
+ class DescriptorsController < ApplicationController
35
+ before_action :set_descriptor, only: %i[ show update destroy ]
36
+
37
+ # GET /descriptors/list.json
38
+ def list
39
+ respond_to do |format|
40
+ format.html {}
41
+ format.json do
42
+ respond_with_successful(DescriptorService.new(current_user, query).list)
43
+ end
44
+ end
45
+ end
46
+
47
+ # GET /descriptors
48
+ def index
49
+ respond_to do |format|
50
+ format.html {}
51
+ format.json do
52
+ #respond_with_successful(DescriptorService.new(current_user, query).index)
53
+ respond_with_pagination(DescriptorService.new(current_user, query).index)
54
+ end
55
+ end
56
+ end
57
+
58
+ # GET /descriptors/:id
59
+ def show
60
+ respond_to do |format|
61
+ format.html {}
62
+ format.json do
63
+ respond_with_successful(@descriptor.show)
64
+ end
65
+ end
66
+ end
67
+
68
+ # GET /descriptors/new
69
+ def new
70
+ end
71
+
72
+ # GET /descriptors/:id/edit
73
+ def edit
74
+ end
75
+
76
+ # POST /descriptors
77
+ def create
78
+ descriptor = DescriptorService.new(current_user, query).create(descriptor_params)
79
+
80
+ # Check if the creation went ok
81
+ if descriptor.successful?
82
+ respond_with_successful(descriptor)
83
+ else
84
+ respond_with_error(descriptor.errors)
85
+ end
86
+ end
87
+
88
+ # PATCH/PUT /descriptors/:id
89
+ def update
90
+ return respond_with_not_found unless @descriptor.found?
91
+
92
+ @descriptor.update(descriptor_params)
93
+
94
+ # Check if the update went ok
95
+ unless @descriptor.successful?
96
+ return respond_with_error(@descriptor.errors)
97
+ end
98
+
99
+ respond_with_successful(@descriptor.result)
100
+ end
101
+
102
+ # DELETE /descriptors/1
103
+ def destroy
104
+ return respond_with_not_found unless @descriptor.found?
105
+
106
+ @descriptor.destroy
107
+
108
+ # Check if the deletion went ok
109
+ unless @descriptor.successful?
110
+ return respond_with_error(@descriptor.errors)
111
+ end
112
+
113
+ respond_with_successful
114
+ end
115
+
116
+ private
117
+
118
+ # Use callbacks to share common setup or constraints between actions.
119
+ def set_descriptor
120
+ @descriptor = DescriptorService.new(current_user, @query).find(params[:id])
121
+ end
122
+
123
+ # Only allow a list of trusted parameters through.
124
+ def descriptor_params
125
+ params.require(:descriptor).permit(:id, :name)
126
+ end
127
+
128
+ end
129
+ end