lesli_security 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
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,207 @@
1
+ <script setup>
2
+ /*
3
+ Lesli
4
+
5
+ Copyright (c) 2023, Lesli Technologies, S. A.
6
+
7
+ This program is free software: you can redistribute it and/or modify
8
+ it under the terms of the GNU General Public License as published by
9
+ the Free Software Foundation, either version 3 of the License, or
10
+ (at your option) any later version.
11
+
12
+ This program is distributed in the hope that it will be useful,
13
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
+ GNU General Public License for more details.
16
+
17
+ You should have received a copy of the GNU General Public License
18
+ along with this program. If not, see http://www.gnu.org/licenses/.
19
+
20
+ Lesli · Ruby on Rails SaaS Development Framework.
21
+
22
+ Made with ♥ by https://www.lesli.tech
23
+ Building a better future, one line of code at a time.
24
+
25
+ @contact hello@lesli.tech
26
+ @website https://www.lesli.tech
27
+ @license GPLv3 http://www.gnu.org/licenses/gpl-3.0.en.html
28
+
29
+ // · ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~
30
+ // ·
31
+ */
32
+
33
+
34
+ // · import vue tools
35
+ import { ref, reactive, onMounted, watch, computed, inject } from "vue"
36
+ import { useRouter, useRoute } from "vue-router"
37
+
38
+
39
+ // · import lesli stores
40
+ import { useUsers } from "LesliSecurity/vue/stores/users"
41
+
42
+
43
+ // · initialize/inject plugins
44
+ const router = useRouter()
45
+ const msg = inject("msg")
46
+ const url = inject("url")
47
+
48
+
49
+ // · implement stores
50
+ const storeUsers = useUsers()
51
+
52
+
53
+ // · translations
54
+ const translations = {
55
+ lesli: {
56
+ shared: i18n.t("lesli.shared")
57
+ },
58
+ guard: {
59
+ users: i18n.t("lesli_security.users")
60
+ },
61
+ core: {
62
+ users: {},
63
+ roles: {},
64
+ shared: {}
65
+ },
66
+
67
+ }
68
+
69
+
70
+ // ·
71
+ const columns = [{
72
+ field: "id",
73
+ label: "ID",
74
+ sort: true
75
+ }, {
76
+ field: "name",
77
+ label: translations.guard.users.table_header_name,
78
+ sort: true
79
+ }, {
80
+ field: "email",
81
+ label: translations.guard.users.table_header_email,
82
+ sort: true
83
+ }, {
84
+ field: "rolenames",
85
+ label: translations.guard.users.table_header_roles,
86
+ sort: true
87
+ }, {
88
+ field: "active",
89
+ label: translations.guard.users.table_header_status,
90
+ sort: true,
91
+ custom: true
92
+ }, {
93
+ field: "current_sign_in_at_string",
94
+ label: translations.guard.users.table_header_last_sign_in,
95
+ sort: true
96
+ }]
97
+
98
+
99
+ // ·
100
+ const selection = ref()
101
+
102
+
103
+ // · defining props
104
+ const props = defineProps({
105
+ appMountPath: {
106
+ type: String,
107
+ required: false,
108
+ default: "lesli/users",
109
+ },
110
+ defaultRole: {
111
+ type: String,
112
+ required: false,
113
+ default: "",
114
+ }
115
+ })
116
+
117
+
118
+ // · initializing
119
+ onMounted(() => {
120
+ storeUsers.fetchUsers()
121
+ })
122
+
123
+
124
+ //
125
+ function showUser(user) {
126
+ router.push(url.root(props.appMountPath+`/${user.id}`).s)
127
+ }
128
+ </script>
129
+ <template>
130
+ <lesli-application-container>
131
+ <lesli-header :title="translations.guard.users.view_title + ' (' + storeUsers.index.pagination.total + ')' ">
132
+ <lesli-button solid icon="add" :to="url.root(props.appMountPath+`/new`)">
133
+ {{ translations.lesli.shared.button_add_new }}
134
+ </lesli-button>
135
+ <lesli-button
136
+ icon="refresh"
137
+ :loading="storeUsers.loading"
138
+ @click="storeUsers.getUsers()">
139
+ {{ translations.lesli.shared.button_reload }}
140
+ </lesli-button>
141
+ </lesli-header>
142
+
143
+ <lesli-toolbar>
144
+ </lesli-toolbar>
145
+ <!--
146
+ <lesli-toolbar
147
+ @search="storeUsers.search"
148
+ :search-placeholder="translations.core.users.view_toolbar_filter_placeholder_search">
149
+ <lesli-select :options="[{
150
+ label: translations.core.users.view_toolbar_filter_placeholder_all_users,
151
+ value: null
152
+ }, {
153
+ label: translations.core.users.view_toolbar_filter_placeholder_active_users,
154
+ value: 'active'
155
+ }, {
156
+ label: translations.core.users.view_toolbar_filter_placeholder_inactive_users,
157
+ value: 'inactive'
158
+ }]"
159
+ v-model="storeUsers.filters.status"
160
+ @change="storeUsers.fetchIndex()">
161
+ </lesli-select>
162
+ <lesli-select :options="storeUsers.roles_options"
163
+ v-model="storeUsers.filters.role"
164
+ @change="storeUsers.fetchIndex()">
165
+ </lesli-select>
166
+ </lesli-toolbar>
167
+ -->
168
+
169
+ <lesli-table
170
+ :loading="storeUsers.loading"
171
+ :columns="columns"
172
+ :records="storeUsers.index.records"
173
+ :pagination="storeUsers.index.pagination"
174
+ :link="(user) => url.security('users/:id', user.id)"
175
+ @paginate="storeUsers.paginateIndex"
176
+ @sort="storeUsers.sortIndex">
177
+
178
+ <template #active="{ value }">
179
+ <span class="tag is-success" v-if="value">
180
+ {{ translations.lesli.shared.view_status_active }}
181
+ </span>
182
+ <span class="tag is-warning" v-if="!value">
183
+ {{ translations.core.shared.view_status_inactive }}
184
+ </span>
185
+ </template>
186
+
187
+ <template #options="{ record, value }">
188
+ <a class="dropdown-item" @click="storeUsers.doLogout(record.id)">
189
+ <span class="material-icons">
190
+ logout
191
+ </span>
192
+ <span>
193
+ {{ translations.core.users.view_btn_logout }}
194
+ </span>
195
+ </a>
196
+ <a class="dropdown-item" @click="storeUsers.doLock(record.id)">
197
+ <span class="material-icons">
198
+ lock
199
+ </span>
200
+ <span>
201
+ {{ translations.core.users.view_btn_revoke_access }}
202
+ </span>
203
+ </a>
204
+ </template>
205
+ </lesli-table>
206
+ </lesli-application-container>
207
+ </template>
@@ -0,0 +1,181 @@
1
+ <script setup>
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 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
+
33
+
34
+ // · import vue tools
35
+ import { onMounted, inject } from "vue"
36
+ import { useRouter, useRoute } from 'vue-router'
37
+
38
+
39
+ // · import lesli stores
40
+ import { useUsers } from "LesliSecurity/vue/stores/users"
41
+ import { useRoles } from "LesliSecurity/vue/stores/roles"
42
+
43
+
44
+ // · implement stores
45
+ const storeUsers = useUsers()
46
+ const storeRoles = useRoles()
47
+ const router = useRouter()
48
+ const route = useRoute()
49
+
50
+
51
+ // · implement composables
52
+ const url = inject("url")
53
+ const msg = inject("msg")
54
+
55
+
56
+ // · translations
57
+ const translations = {
58
+ users: I18n.t("core.users"),
59
+ shared: I18n.t("core.shared")
60
+ }
61
+
62
+
63
+ // ·
64
+ const onCreate = () => {
65
+ storeUsers.postUsers().then(result => {
66
+ storeUsers.user = {}
67
+ msg.success(I18n.t("core.users.messages_success_operation"))
68
+ router.push(url.admin("users/:id", result.id).toString())
69
+ }).catch(error => {
70
+ msg.danger(I18n.t("core.shared.messages_danger_internal_error"))
71
+ })
72
+ }
73
+
74
+
75
+ // ·
76
+ onMounted(() => {
77
+ console.log("works")
78
+ storeRoles.fetchList()
79
+ })
80
+ </script>
81
+ <template>
82
+ <lesli-application>
83
+ <lesli-header title="Create User">
84
+ <lesli-button icon="list" :to="url.admin('users')">
85
+ All users
86
+ </lesli-button>
87
+ </lesli-header>
88
+
89
+ <lesli-form @submit="onCreate()">
90
+ <p>User information</p>
91
+ <div class="field is-horizontal">
92
+ <div class="field-label is-normal">
93
+ <label class="label">
94
+ {{translations.shared.view_text_email}}
95
+ <span class="is-danger">*</span>
96
+ </label>
97
+ </div>
98
+ <div class="field-body">
99
+ <div class="field">
100
+ <div class="control">
101
+ <input name="user_email" v-model="storeUsers.user.email" required="required" type="email" class="input">
102
+ </div>
103
+ </div>
104
+ </div>
105
+ </div>
106
+
107
+ <div class="field is-horizontal">
108
+ <div class="field-label is-normal">
109
+ <label class="label">
110
+ {{ translations.shared.view_text_first_name }}
111
+ </label>
112
+ </div>
113
+ <div class="field-body">
114
+ <div class="field">
115
+ <div class="control">
116
+ <input name="first_name" v-model="storeUsers.user.first_name" type="text" class="input">
117
+ </div>
118
+ </div>
119
+ </div>
120
+ </div>
121
+
122
+ <div class="field is-horizontal">
123
+ <div class="field-label is-normal">
124
+ <label class="label"> {{ translations.shared.view_text_last_name }} </label>
125
+ </div>
126
+ <div class="field-body">
127
+ <div class="field">
128
+ <div class="control">
129
+ <input name="last_name" v-model="storeUsers.user.last_name" class="input">
130
+ </div>
131
+ </div>
132
+ </div>
133
+ </div>
134
+
135
+ <div class="field is-horizontal">
136
+ <div class="field-label is-normal">
137
+ <label class="label"> {{ translations.shared.view_text_telephone }} </label>
138
+ </div>
139
+ <div class="field-body">
140
+ <div class="field">
141
+ <div class="control">
142
+ <input name="user_number" v-model="storeUsers.user.telephone" class="input">
143
+ </div>
144
+ </div>
145
+ </div>
146
+ </div>
147
+
148
+ <div class="field is-horizontal">
149
+ <div class="field-label is-normal">
150
+ <label class="label"> {{ translations.users.view_text_role }} </label>
151
+ </div>
152
+ <div class="field-body">
153
+ <div class="field is-narrow">
154
+ <div class="control">
155
+ <div class="select is-fullwidth">
156
+ <lesli-select
157
+ :options="storeRoles.listOptions"
158
+ v-model="storeUsers.user.roles_id">
159
+ </lesli-select>
160
+ </div>
161
+ </div>
162
+ </div>
163
+ </div>
164
+ </div>
165
+
166
+ <div class="field is-horizontal">
167
+ <div class="field-label is-normal">
168
+ </div>
169
+ <div class="field-body">
170
+ <div class="field">
171
+ <div class="control">
172
+ <lesli-button icon="save">
173
+ {{ translations.shared.view_btn_save }}
174
+ </lesli-button>
175
+ </div>
176
+ </div>
177
+ </div>
178
+ </div>
179
+ </lesli-form>
180
+ </lesli-application>
181
+ </template>
@@ -0,0 +1,131 @@
1
+ <script setup>
2
+ /*
3
+ Lesli
4
+
5
+ Copyright (c) 2023, Lesli Technologies, S. A.
6
+
7
+ This program is free software: you can redistribute it and/or modify
8
+ it under the terms of the GNU General Public License as published by
9
+ the Free Software Foundation, either version 3 of the License, or
10
+ (at your option) any later version.
11
+
12
+ This program is distributed in the hope that it will be useful,
13
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
+ GNU General Public License for more details.
16
+
17
+ You should have received a copy of the GNU General Public License
18
+ along with this program. If not, see http://www.gnu.org/licenses/.
19
+
20
+ Lesli · Ruby on Rails SaaS Development Framework.
21
+
22
+ Made with ♥ by https://www.lesli.tech
23
+ Building a better future, one line of code at a time.
24
+
25
+ @contact hello@lesli.tech
26
+ @website https://www.lesli.tech
27
+ @license GPLv3 http://www.gnu.org/licenses/gpl-3.0.en.html
28
+
29
+ // · ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~
30
+ // ·
31
+ */
32
+
33
+
34
+ // · import vue tools
35
+ import { ref, onMounted } from "vue"
36
+ import { useRouter, useRoute } from 'vue-router'
37
+
38
+
39
+ // · import lesli stores
40
+ import { useUser } from "LesliSecurity/vue/stores/user"
41
+
42
+
43
+ // · implement stores
44
+ const storeUser = useUser()
45
+ const router = useRouter()
46
+ const route = useRoute()
47
+
48
+
49
+ // · import profile components
50
+ import informationCard from "LesliSecurity/vue/apps/users/components/information-card.vue"
51
+ import informationForm from "LesliSecurity/vue/apps/users/components/information-form.vue"
52
+ import managementRoles from "LesliSecurity/vue/apps/users/components/management-roles.vue"
53
+ import managementSession from "LesliSecurity/vue/apps/users/components/management-sessions.vue"
54
+ import managementSettings from "LesliSecurity/vue/apps/users/components/management-settings.vue"
55
+ import managementSecurity from "LesliSecurity/vue/apps/users/components/management-security.vue"
56
+
57
+
58
+ // · translations
59
+ const translations = {
60
+ guard: {
61
+ users: i18n.t("lesli_security.users")
62
+ },
63
+ core: {
64
+ roles: I18n.t("core.roles"),
65
+ users: I18n.t("core.users"),
66
+ shared: I18n.t("core.shared")
67
+ }
68
+ }
69
+
70
+
71
+ // ·
72
+ const tab = ref(0)
73
+
74
+
75
+ // · initializing
76
+ onMounted(() => {
77
+ // storeUser.$reset()
78
+ // storeUser.getOptions()
79
+ if (route.params?.id) {
80
+ storeUser.getUser(route.params?.id)
81
+ } else {
82
+ storeUser.getUser(lesli.current_user.id)
83
+ }
84
+ })
85
+ </script>
86
+ <template>
87
+ <lesli-application-container>
88
+ <information-card></information-card>
89
+ <lesli-tabs v-model="tab">
90
+ <lesli-tab-item icon="info_outline" :title="translations.guard.users.tab_information">
91
+ <information-form></information-form>
92
+ </lesli-tab-item>
93
+
94
+ <lesli-tab-item icon="security" :title="translations.guard.users.tab_roles_and_privileges">
95
+ <management-roles></management-roles>
96
+ </lesli-tab-item>
97
+
98
+ <lesli-tab-item icon="lock_outline" :title="translations.guard.users.tab_security">
99
+ <management-security></management-security>
100
+ </lesli-tab-item>
101
+
102
+ <lesli-tab-item icon="devices" :title="translations.guard.users.tab_sessions">
103
+ <management-session></management-session>
104
+ </lesli-tab-item>
105
+
106
+ <lesli-tab-item icon="settings" :title="translations.guard.users.tab_settings">
107
+ <management-settings></management-settings>
108
+ </lesli-tab-item>
109
+ </lesli-tabs>
110
+ </lesli-application-container>
111
+ <!--
112
+ <application-component>
113
+ <information-card></information-card>
114
+ <lesli-tabs v-model="tab" v-if="storeUser.user.id">
115
+ <lesli-tab-item icon="info_outline" :title="translations.core.users.view_tab_title_information">
116
+ <information-form></information-form>
117
+ </lesli-tab-item>
118
+
119
+ <lesli-tab-item icon="lock_outline" :title="translations.core.users.view_tab_title_security || 'Security'">
120
+ <management-security></management-security>
121
+ </lesli-tab-item>
122
+ <lesli-tab-item icon="devices" :title="translations.core.users.view_tab_title_session || 'Sessions'" paddingless>
123
+ <management-session></management-session>
124
+ </lesli-tab-item>
125
+ <lesli-tab-item icon="settings" :title="translations.core.users.view_tab_title_settings">
126
+ <management-settings></management-settings>
127
+ </lesli-tab-item>
128
+ </lesli-tabs>
129
+ </application-component>
130
+ -->
131
+ </template>
@@ -0,0 +1,117 @@
1
+ /*
2
+ Lesli
3
+
4
+ Copyright (c) 2023, Lesli Technologies, S. A.
5
+
6
+ This program is free software: you can redistribute it and/or modify
7
+ it under the terms of the GNU General Public License as published by
8
+ the Free Software Foundation, either version 3 of the License, or
9
+ (at your option) any later version.
10
+
11
+ This program is distributed in the hope that it will be useful,
12
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
+ GNU General Public License for more details.
15
+
16
+ You should have received a copy of the GNU General Public License
17
+ along with this program. If not, see http://www.gnu.org/licenses/.
18
+
19
+ Lesli · Ruby on Rails SaaS Development Framework.
20
+
21
+ Made with ♥ by https://www.lesli.tech
22
+ Building a better future, one line of code at a time.
23
+
24
+ @contact hello@lesli.tech
25
+ @website https://www.lesli.tech
26
+ @license GPLv3 http://www.gnu.org/licenses/gpl-3.0.en.html
27
+
28
+ // · ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~
29
+ // ·
30
+ */
31
+
32
+
33
+ // ·
34
+ import { defineStore } from "pinia"
35
+
36
+
37
+ // ·
38
+ export const useDescriptor = defineStore("guard.descriptor", {
39
+ state: () => {
40
+ return {
41
+ descriptor: {
42
+ loading: false,
43
+ payload: {
44
+ name: ""
45
+ }
46
+ },
47
+ privileges: [],
48
+ privilegesLoading: false
49
+ }
50
+ },
51
+ actions: {
52
+
53
+ getDescriptor(id) {
54
+ this.http.get(this.url.security("descriptors/:id", id)).then(result => {
55
+ this.descriptor = result
56
+ this.getDescriptorPrivileges()
57
+ }).catch(error => {
58
+ this.msg.danger(I18n.t("core.shared.messages_danger_internal_error"))
59
+ }).finally(() => {
60
+
61
+ })
62
+ },
63
+
64
+ resetDescriptor() {
65
+ },
66
+
67
+ postDescriptor() {
68
+ this.loading = true
69
+ this.http.post(this.url.security("descriptors"), {
70
+ descriptor: this.descriptor.payload
71
+ }).then(result => {
72
+ this.descriptor.payload.id = result.id
73
+ this.msg.success(I18n.t("core.users.messages_success_operation"))
74
+ }).catch(error => {
75
+ this.msg.danger(I18n.t("core.shared.messages_danger_internal_error"))
76
+ }).finally(() => {
77
+ this.loading = false
78
+ })
79
+ },
80
+
81
+ getDescriptorPrivileges() {
82
+ this.privilegesLoading = true
83
+ this.http.get(this.url.security("descriptors/:id/privileges", this.descriptor.id)).then(result => {
84
+ this.privileges = result
85
+ }).catch(error => {
86
+ console.log(error)
87
+ }).finally(() => {
88
+ this.privilegesLoading = false
89
+ })
90
+ },
91
+
92
+ // Add privilege to descriptor
93
+ postDescriptorPrivilege(action) {
94
+ this.http.post(this.url.security("descriptors/:id/privileges", this.descriptor.id), {
95
+ descriptor_privilege: {
96
+ action_id: action
97
+ }
98
+ }).then(result => {
99
+ console.log(result)
100
+ }).catch(error => {
101
+ console.log(error)
102
+ })
103
+ },
104
+
105
+ // Add privilege to descriptor
106
+ deleteDescriptorPrivilege(action) {
107
+ this.http.delete(this.url.security("descriptors/:descriptorId/privileges/:descriptorPrivilegeId", {
108
+ descriptorId: this.descriptor.id,
109
+ descriptorPrivilegeId: action
110
+ })).then(result => {
111
+ console.log(result)
112
+ }).catch(error => {
113
+ console.log(error)
114
+ })
115
+ }
116
+ }
117
+ })