lesli_vault 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/Rakefile +38 -0
- data/app/assets/config/lesli_vault_manifest.js +38 -0
- data/app/assets/images/lesli_vault/vault-logo.svg +160 -0
- data/app/assets/javascripts/lesli_vault/application.js +2848 -0
- data/app/assets/stylesheets/lesli_vault/application.scss +15 -0
- data/app/assets/stylesheets/lesli_vault/dashboards.scss +32 -0
- data/app/assets/stylesheets/lesli_vault/descriptors.scss +32 -0
- data/app/assets/stylesheets/lesli_vault/roles.scss +32 -0
- data/app/assets/stylesheets/lesli_vault/system_controller.scss +32 -0
- data/app/controllers/lesli_vault/application_controller.rb +37 -0
- data/app/controllers/lesli_vault/dashboards_controller.rb +6 -0
- data/app/controllers/lesli_vault/descriptor/activities_controller.rb +122 -0
- data/app/controllers/lesli_vault/descriptor/privileges_controller.rb +104 -0
- data/app/controllers/lesli_vault/descriptors_controller.rb +130 -0
- data/app/controllers/lesli_vault/role/activities_controller.rb +76 -0
- data/app/controllers/lesli_vault/role/descriptors_controller.rb +95 -0
- data/app/controllers/lesli_vault/role/privileges_controller.rb +48 -0
- data/app/controllers/lesli_vault/roles_controller.rb +226 -0
- data/app/controllers/lesli_vault/system_controller/actions_controller.rb +112 -0
- data/app/controllers/lesli_vault/system_controllers_controller.rb +64 -0
- data/app/helpers/lesli_vault/application_helper.rb +4 -0
- data/app/helpers/lesli_vault/dashboards_helper.rb +4 -0
- data/app/helpers/lesli_vault/descriptor/activities_helper.rb +4 -0
- data/app/helpers/lesli_vault/descriptor/privileges_helper.rb +4 -0
- data/app/helpers/lesli_vault/descriptors_helper.rb +4 -0
- data/app/helpers/lesli_vault/role/activities_helper.rb +4 -0
- data/app/helpers/lesli_vault/role/descriptors_helper.rb +4 -0
- data/app/helpers/lesli_vault/role/privileges_helper.rb +4 -0
- data/app/helpers/lesli_vault/roles_helper.rb +4 -0
- data/app/helpers/lesli_vault/system_controller/actions_helper.rb +4 -0
- data/app/helpers/lesli_vault/system_controllers_helper.rb +4 -0
- data/app/jobs/lesli_vault/application_job.rb +37 -0
- data/app/mailers/lesli_vault/application_mailer.rb +39 -0
- data/app/models/lesli_vault/application_record.rb +39 -0
- data/app/models/lesli_vault/descriptor/activity.rb +40 -0
- data/app/models/lesli_vault/descriptor/privilege.rb +40 -0
- data/app/models/lesli_vault/descriptor.rb +41 -0
- data/app/models/lesli_vault/role/activity.rb +40 -0
- data/app/models/lesli_vault/role/descriptor.rb +40 -0
- data/app/models/lesli_vault/role/privilege.rb +40 -0
- data/app/models/lesli_vault/role.rb +39 -0
- data/app/models/lesli_vault/system_controller/action.rb +39 -0
- data/app/models/lesli_vault/system_controller.rb +40 -0
- data/app/services/application_lesli_services.rb +168 -0
- data/app/services/descriptor_services.rb +197 -0
- data/app/services/role_services.rb +218 -0
- data/app/services/system_controller_services.rb +99 -0
- data/app/views/layouts/lesli_vault/application.html.erb +15 -0
- data/app/views/lesli_vault/dashboards/show.html.erb +1 -0
- data/app/views/lesli_vault/descriptor/activities/_form.html.erb +32 -0
- data/app/views/lesli_vault/descriptor/activities/edit.html.erb +34 -0
- data/app/views/lesli_vault/descriptor/activities/index.html.erb +34 -0
- data/app/views/lesli_vault/descriptor/activities/new.html.erb +34 -0
- data/app/views/lesli_vault/descriptor/activities/show.html.erb +34 -0
- data/app/views/lesli_vault/descriptor/privileges/_form.html.erb +32 -0
- data/app/views/lesli_vault/descriptor/privileges/edit.html.erb +34 -0
- data/app/views/lesli_vault/descriptor/privileges/index.html.erb +34 -0
- data/app/views/lesli_vault/descriptor/privileges/new.html.erb +34 -0
- data/app/views/lesli_vault/descriptor/privileges/show.html.erb +34 -0
- data/app/views/lesli_vault/descriptors/_form.html.erb +32 -0
- data/app/views/lesli_vault/descriptors/edit.html.erb +34 -0
- data/app/views/lesli_vault/descriptors/index.html.erb +34 -0
- data/app/views/lesli_vault/descriptors/new.html.erb +34 -0
- data/app/views/lesli_vault/descriptors/show.html.erb +34 -0
- data/app/views/lesli_vault/role/activities/_form.html.erb +32 -0
- data/app/views/lesli_vault/role/activities/edit.html.erb +34 -0
- data/app/views/lesli_vault/role/activities/index.html.erb +34 -0
- data/app/views/lesli_vault/role/activities/new.html.erb +34 -0
- data/app/views/lesli_vault/role/activities/show.html.erb +34 -0
- data/app/views/lesli_vault/role/descriptors/_form.html.erb +32 -0
- data/app/views/lesli_vault/role/descriptors/edit.html.erb +34 -0
- data/app/views/lesli_vault/role/descriptors/index.html.erb +34 -0
- data/app/views/lesli_vault/role/descriptors/new.html.erb +34 -0
- data/app/views/lesli_vault/role/descriptors/show.html.erb +34 -0
- data/app/views/lesli_vault/role/privileges/_form.html.erb +32 -0
- data/app/views/lesli_vault/role/privileges/edit.html.erb +34 -0
- data/app/views/lesli_vault/role/privileges/index.html.erb +34 -0
- data/app/views/lesli_vault/role/privileges/new.html.erb +34 -0
- data/app/views/lesli_vault/role/privileges/show.html.erb +34 -0
- data/app/views/lesli_vault/roles/edit.html.erb +34 -0
- data/app/views/lesli_vault/roles/index.html.erb +34 -0
- data/app/views/lesli_vault/roles/new.html.erb +34 -0
- data/app/views/lesli_vault/roles/show.html.erb +34 -0
- data/app/views/lesli_vault/system_controller/actions/_form.html.erb +32 -0
- data/app/views/lesli_vault/system_controller/actions/edit.html.erb +34 -0
- data/app/views/lesli_vault/system_controller/actions/index.html.erb +34 -0
- data/app/views/lesli_vault/system_controller/actions/new.html.erb +34 -0
- data/app/views/lesli_vault/system_controller/actions/show.html.erb +34 -0
- data/app/views/lesli_vault/system_controllers/_form.html.erb +32 -0
- data/app/views/lesli_vault/system_controllers/edit.html.erb +34 -0
- data/app/views/lesli_vault/system_controllers/index.html.erb +34 -0
- data/app/views/lesli_vault/system_controllers/new.html.erb +34 -0
- data/app/views/lesli_vault/system_controllers/show.html.erb +34 -0
- data/app/vue/lesli_vault/application.js +38 -0
- data/app/vue/lesli_vault/apps/descriptors/components/form.vue +147 -0
- data/app/vue/lesli_vault/apps/descriptors/edit.vue +83 -0
- data/app/vue/lesli_vault/apps/descriptors/index.vue +116 -0
- data/app/vue/lesli_vault/apps/descriptors/new.vue +76 -0
- data/app/vue/lesli_vault/apps/descriptors/privileges.vue +179 -0
- data/app/vue/lesli_vault/apps/descriptors/show.vue +240 -0
- data/app/vue/lesli_vault/apps/roles/componentForm.vue +231 -0
- data/app/vue/lesli_vault/apps/roles/componentPrivilegeCustom.vue +86 -0
- data/app/vue/lesli_vault/apps/roles/componentPrivilegeStandard.vue +173 -0
- data/app/vue/lesli_vault/apps/roles/edit.vue +93 -0
- data/app/vue/lesli_vault/apps/roles/index.vue +169 -0
- data/app/vue/lesli_vault/apps/roles/logs.vue +110 -0
- data/app/vue/lesli_vault/apps/roles/new.vue +89 -0
- data/app/vue/lesli_vault/apps/roles/show.vue +111 -0
- data/app/vue/lesli_vault/apps/security/index.vue +208 -0
- data/app/vue/lesli_vault/stores/descriptor.js +116 -0
- data/app/vue/lesli_vault/stores/descriptors.js +167 -0
- data/app/vue/lesli_vault/stores/role.js +243 -0
- data/app/vue/lesli_vault/stores/roles.js +89 -0
- data/app/vue/lesli_vault/stores/systemController.js +67 -0
- data/config/routes.rb +52 -0
- data/lib/lesli_vault/engine.rb +18 -0
- data/lib/lesli_vault/version.rb +3 -0
- data/lib/lesli_vault.rb +6 -0
- data/lib/tasks/lesli_vault_tasks.rake +4 -0
- data/lib/tasks/system/controllers.rake +112 -0
- data/lib/vue/application.js +7 -0
- data/readme.md +19 -0
- metadata +181 -0
|
@@ -0,0 +1,95 @@
|
|
|
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 LesliVault
|
|
35
|
+
class Role::DescriptorsController < ApplicationController
|
|
36
|
+
before_action :set_role, only: %i[ index show update create destroy ]
|
|
37
|
+
before_action :set_role_descriptor, only: %i[ show update destroy ]
|
|
38
|
+
|
|
39
|
+
def index
|
|
40
|
+
respond_with_successful(Role::Descriptor.index(current_user, @query, @role))
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
# POST /role/descriptors
|
|
44
|
+
def create
|
|
45
|
+
|
|
46
|
+
role_descriptor_status = false
|
|
47
|
+
|
|
48
|
+
system_descriptor = Descriptor.find_by(:id => role_descriptor_params[:id])
|
|
49
|
+
role_descriptor = @role.descriptors.with_deleted.find_by(:descriptor => system_descriptor)
|
|
50
|
+
|
|
51
|
+
if not role_descriptor
|
|
52
|
+
role_descriptor = @role.descriptors.new(:descriptor => system_descriptor)
|
|
53
|
+
role_descriptor_status = role_descriptor.save
|
|
54
|
+
elsif role_descriptor.deleted?
|
|
55
|
+
role_descriptor_status = role_descriptor.recover
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
if role_descriptor_status
|
|
59
|
+
#Role::Activity.log_create_descriptor(current_user, @role, role_descriptor)
|
|
60
|
+
respond_with_successful(role_descriptor)
|
|
61
|
+
else
|
|
62
|
+
respond_with_error(role_descriptor.errors.full_messages.to_sentence)
|
|
63
|
+
end
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
# DELETE /role/descriptors/1
|
|
67
|
+
def destroy
|
|
68
|
+
return respond_with_not_found unless @role_descriptor
|
|
69
|
+
|
|
70
|
+
if @role_descriptor.destroy
|
|
71
|
+
Role::Activity.log_destroy_descriptor(current_user, @role, @role_descriptor)
|
|
72
|
+
respond_with_successful
|
|
73
|
+
else
|
|
74
|
+
respond_with_error(@role_descriptor.errors.full_messages.to_sentence)
|
|
75
|
+
end
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
private
|
|
79
|
+
|
|
80
|
+
def set_role
|
|
81
|
+
@role = current_user.account.roles.find_by(id: params[:role_id])
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
def set_role_descriptor
|
|
85
|
+
return respond_with_not_found unless @role
|
|
86
|
+
@role_descriptor = @role.descriptors.find_by(system_descriptors_id: params[:id])
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
# Only allow a list of trusted parameters through.
|
|
90
|
+
def role_descriptor_params
|
|
91
|
+
params.require(:role_descriptor).permit(:id, :name, :privilege_index)
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
end
|
|
95
|
+
end
|
|
@@ -0,0 +1,48 @@
|
|
|
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 LesliVault
|
|
35
|
+
class Role::PrivilegesController < ApplicationController
|
|
36
|
+
before_action :set_role_privilege, only: %i[]
|
|
37
|
+
|
|
38
|
+
private
|
|
39
|
+
|
|
40
|
+
# Use callbacks to share common setup or constraints between actions.
|
|
41
|
+
def set_role_privilege
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
# Only allow a list of trusted parameters through.
|
|
45
|
+
def role_privilege_params
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
end
|
|
@@ -0,0 +1,226 @@
|
|
|
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 LesliVault
|
|
35
|
+
class RolesController < ApplicationController
|
|
36
|
+
|
|
37
|
+
before_action :set_role, only: %i[ show update destroy ]
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
#@return [HTML|JSON] HTML view for listing all roles or a Json that contains a list of all roles
|
|
41
|
+
# associated to this *account*
|
|
42
|
+
#@description Retrieves and returns all roles associated to a *CloudHouse::Account*. The account
|
|
43
|
+
# is obtained directly from *current_user*. The HTTP request has to specify
|
|
44
|
+
# wheter the HTML or the JSON text should be rendered
|
|
45
|
+
#@example
|
|
46
|
+
# # Executing this controller's action from javascript's frontend
|
|
47
|
+
# this.http.get(`127.0.0.1/house/roles`);
|
|
48
|
+
def list
|
|
49
|
+
respond_to do |format|
|
|
50
|
+
format.html { }
|
|
51
|
+
format.json { respond_with_successful(RoleServices.new(current_user).list) }
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
#@return [HTML|JSON] HTML view for listing all roles or a Json that contains a list of all roles
|
|
56
|
+
# associated to this *account*
|
|
57
|
+
#@description Retrieves and returns all roles associated to a *CloudHouse::Account*. The account
|
|
58
|
+
# is obtained directly from *current_user*. The HTTP request has to specify
|
|
59
|
+
# wheter the HTML or the JSON text should be rendered
|
|
60
|
+
#@example
|
|
61
|
+
# # Executing this controller's action from javascript's frontend
|
|
62
|
+
# this.http.get(`127.0.0.1/house/roles`);
|
|
63
|
+
def index
|
|
64
|
+
respond_to do |format|
|
|
65
|
+
format.html { }
|
|
66
|
+
format.json {
|
|
67
|
+
respond_with_pagination(RoleServices.new(current_user, @query).index)
|
|
68
|
+
}
|
|
69
|
+
end
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
# @return [HTML|Json] HTML view showing the requested role or a Json that contains the
|
|
73
|
+
# information of the role. If there is an error, an explanation message is sent
|
|
74
|
+
# @description Retrieves and returns the requested roles. The id of the
|
|
75
|
+
# role is within the *params* attribute of the controller. The HTTP request has to specify
|
|
76
|
+
# wheter the HTML or the JSON text should be rendered. This is the only method that uses the role
|
|
77
|
+
# code instead of the ID for searching.
|
|
78
|
+
# @example
|
|
79
|
+
# # Executing this controller's action from javascript's frontend
|
|
80
|
+
# let role_id = 1;
|
|
81
|
+
# this.http.get(`127.0.0.1/roles/${role_id}`);
|
|
82
|
+
def show
|
|
83
|
+
respond_to do |format|
|
|
84
|
+
format.html { }
|
|
85
|
+
format.json {
|
|
86
|
+
return respond_with_not_found unless @role.found?
|
|
87
|
+
|
|
88
|
+
respond_with_successful(@role.show)
|
|
89
|
+
}
|
|
90
|
+
end
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
# @return [HTML] HTML view for creating a new role
|
|
94
|
+
# @description returns an HTML view with a form so users can create a new role
|
|
95
|
+
# @example
|
|
96
|
+
# # Executing this controller's action from javascript's frontend
|
|
97
|
+
# this.url.go('/roles/new')
|
|
98
|
+
def new
|
|
99
|
+
end
|
|
100
|
+
|
|
101
|
+
# @return [HTML] HTML view for editing the role
|
|
102
|
+
# @description returns an HTML view with a form so users edit an existing role
|
|
103
|
+
# @example
|
|
104
|
+
# # Executing this controller's action from javascript's frontend
|
|
105
|
+
# let role_id = 3;
|
|
106
|
+
# this.url.go(`/roles/${role_id}/edit`)
|
|
107
|
+
def edit
|
|
108
|
+
end
|
|
109
|
+
|
|
110
|
+
# @return [Json] Json that contains wheter the creation of the role was successful or not.
|
|
111
|
+
# If it is not successful, it returns an error message
|
|
112
|
+
# @description Creates a new role associated to the *current_user*'s *account*.
|
|
113
|
+
# @example
|
|
114
|
+
# # Executing this controller's action from javascript's frontend
|
|
115
|
+
# let data = {
|
|
116
|
+
# role: {
|
|
117
|
+
# name: "Change Request"
|
|
118
|
+
# }
|
|
119
|
+
# };
|
|
120
|
+
# this.http.post('127.0.0.1/house/roles', data);
|
|
121
|
+
def create
|
|
122
|
+
|
|
123
|
+
role = RoleServices.new(current_user)
|
|
124
|
+
role.create(role_params)
|
|
125
|
+
|
|
126
|
+
unless role.successful?
|
|
127
|
+
respond_with_error(role.errors)
|
|
128
|
+
end
|
|
129
|
+
|
|
130
|
+
respond_with_successful(role)
|
|
131
|
+
end
|
|
132
|
+
|
|
133
|
+
# @controller_action_param :name [String] The name of the role
|
|
134
|
+
# @return [Json] Json that contains wheter the role was successfully updated or not.
|
|
135
|
+
# If it it not successful, it returns an error message
|
|
136
|
+
# @description Updates an existing role associated to the *current_user*'s *account*.
|
|
137
|
+
def update
|
|
138
|
+
# Respond with 404 if role was not found
|
|
139
|
+
return respond_with_not_found unless @role.found?
|
|
140
|
+
|
|
141
|
+
# check if current user can work with role
|
|
142
|
+
unless current_user.can_work_with_role?(@role.resource)
|
|
143
|
+
return respond_with_error(I18n.t("core.roles.messages_danger_updating_role_object_level_permission_too_high"))
|
|
144
|
+
end
|
|
145
|
+
|
|
146
|
+
# Update role information
|
|
147
|
+
@role.update(role_params)
|
|
148
|
+
|
|
149
|
+
# check if the update went OK
|
|
150
|
+
unless @role.successful?
|
|
151
|
+
respond_with_error(@role.errors)
|
|
152
|
+
end
|
|
153
|
+
|
|
154
|
+
respond_with_successful(@role)
|
|
155
|
+
end
|
|
156
|
+
|
|
157
|
+
# @return [Json] Json that contains wheter the role was successfully deleted or not.
|
|
158
|
+
# If it it not successful, it returns an error message
|
|
159
|
+
# @description Deletes an existing *role* associated to the *current_user*'s *account*.
|
|
160
|
+
def destroy
|
|
161
|
+
return respond_with_not_found unless @role.found?
|
|
162
|
+
|
|
163
|
+
# Validation: check if the role has still associated users
|
|
164
|
+
if @role.has_users?
|
|
165
|
+
return respond_with_error(I18n.t("core.roles.messages_danger_users_assigned_validation"))
|
|
166
|
+
end
|
|
167
|
+
|
|
168
|
+
@role.destroy
|
|
169
|
+
|
|
170
|
+
# Check if the deletion went ok
|
|
171
|
+
unless @role.successful?
|
|
172
|
+
return respond_with_error(@role.errors)
|
|
173
|
+
end
|
|
174
|
+
|
|
175
|
+
respond_with_successful
|
|
176
|
+
end
|
|
177
|
+
|
|
178
|
+
# @return [JSON]
|
|
179
|
+
# @description Gets all the specific options for roles CRUD
|
|
180
|
+
def options
|
|
181
|
+
respond_with_successful({
|
|
182
|
+
:object_level_permissions => RoleServices.new(current_user).options
|
|
183
|
+
})
|
|
184
|
+
end
|
|
185
|
+
|
|
186
|
+
private
|
|
187
|
+
|
|
188
|
+
# @return [void]
|
|
189
|
+
# @description Sets the requested user based on the current_users's account
|
|
190
|
+
# @example
|
|
191
|
+
# # Executing this method from a controller action:
|
|
192
|
+
# set_role
|
|
193
|
+
# puts @role
|
|
194
|
+
# # This will either display nil or an instance of Role
|
|
195
|
+
def set_role
|
|
196
|
+
@role = RoleServices.new(current_user).find(params[:id])
|
|
197
|
+
end
|
|
198
|
+
|
|
199
|
+
# @return [Parameters] Allowed parameters for the role
|
|
200
|
+
# @description Sanitizes the parameters received from an HTTP call to only allow the specified ones.
|
|
201
|
+
# Allowed params are detail_attributes: [:name, :active, :object_level_permission]
|
|
202
|
+
# @example
|
|
203
|
+
# # suppose params contains {
|
|
204
|
+
# # "role": {
|
|
205
|
+
# # "name": "Admin",
|
|
206
|
+
# # "word": Hello
|
|
207
|
+
# # }
|
|
208
|
+
# #}
|
|
209
|
+
# filtered_params = role_params
|
|
210
|
+
# puts filtered_params
|
|
211
|
+
# # will remove all unpermitted attributes and only print {
|
|
212
|
+
# # "name": "Admin",
|
|
213
|
+
# #}
|
|
214
|
+
def role_params
|
|
215
|
+
params.fetch(:role, {}).permit(
|
|
216
|
+
:name,
|
|
217
|
+
:active,
|
|
218
|
+
:only_my_data,
|
|
219
|
+
:default_path,
|
|
220
|
+
:limit_to_path,
|
|
221
|
+
:object_level_permission
|
|
222
|
+
)
|
|
223
|
+
end
|
|
224
|
+
|
|
225
|
+
end
|
|
226
|
+
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 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 LesliVault
|
|
35
|
+
class SystemController::ActionsController < ApplicationController
|
|
36
|
+
before_action :set_system_controllers_action, only: %i[ show update destroy ]
|
|
37
|
+
|
|
38
|
+
# GET /system_controllers/actions
|
|
39
|
+
def index
|
|
40
|
+
respond_to do |format|
|
|
41
|
+
format.html {}
|
|
42
|
+
format.json do
|
|
43
|
+
respond_with_successful(SystemControllers::Action.index(current_user, @query))
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
# GET /system_controllers/actions/1
|
|
49
|
+
def show
|
|
50
|
+
respond_to do |format|
|
|
51
|
+
format.html {}
|
|
52
|
+
format.json do
|
|
53
|
+
return respond_with_not_found unless @system_controllers_action
|
|
54
|
+
return respond_with_successful(@system_controllers_action.show(current_user, @query))
|
|
55
|
+
end
|
|
56
|
+
end
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
# GET /system_controllers/actions/new
|
|
60
|
+
def new
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
# GET /system_controllers/actions/1/edit
|
|
64
|
+
def edit
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
# POST /system_controllers/actions
|
|
68
|
+
def create
|
|
69
|
+
system_controllers_action = SystemControllers::Action.new(system_controllers_action_params)
|
|
70
|
+
if system_controllers_action.save
|
|
71
|
+
respond_with_successful(system_controllers_action)
|
|
72
|
+
else
|
|
73
|
+
respond_with_error(system_controllers_action.errors.full_messages.to_sentence)
|
|
74
|
+
end
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
# PATCH/PUT /system_controllers/actions/1
|
|
78
|
+
def update
|
|
79
|
+
return respond_with_not_found unless @system_controllers_action
|
|
80
|
+
|
|
81
|
+
if @system_controllers_action.update(system_controllers_action_params)
|
|
82
|
+
respond_with_successful(@system_controllers_action.show(current_user, @query))
|
|
83
|
+
else
|
|
84
|
+
respond_with_error(@system_controllers_action.errors.full_messages.to_sentence)
|
|
85
|
+
end
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
# DELETE /system_controllers/actions/1
|
|
89
|
+
def destroy
|
|
90
|
+
return respond_with_not_found unless @system_controllers_action
|
|
91
|
+
|
|
92
|
+
if @system_controllers_action.destroy
|
|
93
|
+
respond_with_successful
|
|
94
|
+
else
|
|
95
|
+
respond_with_error(@system_controllers_action.errors.full_messages.to_sentence)
|
|
96
|
+
end
|
|
97
|
+
end
|
|
98
|
+
|
|
99
|
+
private
|
|
100
|
+
|
|
101
|
+
# Use callbacks to share common setup or constraints between actions.
|
|
102
|
+
def set_system_controllers_action
|
|
103
|
+
@system_controllers_action = current_user.account.system_controllers_actions.find(class_name, params[:id])
|
|
104
|
+
end
|
|
105
|
+
|
|
106
|
+
# Only allow a list of trusted parameters through.
|
|
107
|
+
def system_controllers_action_params
|
|
108
|
+
params.require(:system_controllers_action).permit(:id, :name)
|
|
109
|
+
end
|
|
110
|
+
|
|
111
|
+
end
|
|
112
|
+
end
|
|
@@ -0,0 +1,64 @@
|
|
|
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 LesliVault
|
|
35
|
+
class SystemControllersController < ApplicationController
|
|
36
|
+
before_action :set_system_controller, only: %i[ show update destroy ]
|
|
37
|
+
|
|
38
|
+
# GET /system_controllers
|
|
39
|
+
def index
|
|
40
|
+
respond_to do |format|
|
|
41
|
+
format.html {}
|
|
42
|
+
format.json do
|
|
43
|
+
respond_with_successful(SystemControllerServices.new(current_user).index)
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
def options
|
|
49
|
+
respond_to do |format|
|
|
50
|
+
format.html {}
|
|
51
|
+
format.json do
|
|
52
|
+
respond_with_successful(SystemControllerServices.new(current_user).options)
|
|
53
|
+
end
|
|
54
|
+
end
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
private
|
|
58
|
+
|
|
59
|
+
# Only allow a list of trusted parameters through.
|
|
60
|
+
def system_controller_params
|
|
61
|
+
[]
|
|
62
|
+
end
|
|
63
|
+
end
|
|
64
|
+
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 LesliVault
|
|
35
|
+
class ApplicationJob < ActiveJob::Base
|
|
36
|
+
end
|
|
37
|
+
end
|
|
@@ -0,0 +1,39 @@
|
|
|
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 LesliVault
|
|
35
|
+
class ApplicationMailer < ActionMailer::Base
|
|
36
|
+
default from: "from@example.com"
|
|
37
|
+
layout "mailer"
|
|
38
|
+
end
|
|
39
|
+
end
|