lesli_guard 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (141) hide show
  1. checksums.yaml +7 -0
  2. data/Rakefile +38 -0
  3. data/app/assets/config/lesli_guard_manifest.js +38 -0
  4. data/app/assets/images/lesli_guard/guard-logo.svg +160 -0
  5. data/app/assets/javascripts/lesli_guard/application.js +4787 -0
  6. data/app/assets/stylesheets/lesli_guard/application.scss +33 -0
  7. data/app/assets/stylesheets/lesli_guard/dashboards.scss +32 -0
  8. data/app/assets/stylesheets/lesli_guard/descriptors.scss +32 -0
  9. data/app/assets/stylesheets/lesli_guard/roles.scss +32 -0
  10. data/app/assets/stylesheets/lesli_guard/system_controller.scss +32 -0
  11. data/app/assets/stylesheets/lesli_guard/users.scss +67 -0
  12. data/app/controllers/lesli_guard/accounts_controller.rb +60 -0
  13. data/app/controllers/lesli_guard/application_controller.rb +37 -0
  14. data/app/controllers/lesli_guard/dashboard/components_controller.rb +60 -0
  15. data/app/controllers/lesli_guard/dashboards_controller.rb +36 -0
  16. data/app/controllers/lesli_guard/descriptor/activities_controller.rb +122 -0
  17. data/app/controllers/lesli_guard/descriptor/privileges_controller.rb +112 -0
  18. data/app/controllers/lesli_guard/descriptors_controller.rb +129 -0
  19. data/app/controllers/lesli_guard/role/activities_controller.rb +76 -0
  20. data/app/controllers/lesli_guard/role/descriptors_controller.rb +97 -0
  21. data/app/controllers/lesli_guard/role/privileges_controller.rb +47 -0
  22. data/app/controllers/lesli_guard/roles_controller.rb +185 -0
  23. data/app/controllers/lesli_guard/user/roles_controller.rb +98 -0
  24. data/app/controllers/lesli_guard/user/sessions_controller.rb +71 -0
  25. data/app/controllers/lesli_guard/users_controller.rb +206 -0
  26. data/app/helpers/lesli_guard/accounts_helper.rb +4 -0
  27. data/app/helpers/lesli_guard/application_helper.rb +4 -0
  28. data/app/helpers/lesli_guard/dashboards_helper.rb +4 -0
  29. data/app/helpers/lesli_guard/descriptor/activities_helper.rb +4 -0
  30. data/app/helpers/lesli_guard/descriptor/privileges_helper.rb +4 -0
  31. data/app/helpers/lesli_guard/descriptors_helper.rb +4 -0
  32. data/app/helpers/lesli_guard/role/activities_helper.rb +4 -0
  33. data/app/helpers/lesli_guard/role/descriptors_helper.rb +4 -0
  34. data/app/helpers/lesli_guard/role/privileges_helper.rb +4 -0
  35. data/app/helpers/lesli_guard/roles_helper.rb +4 -0
  36. data/app/jobs/lesli_guard/application_job.rb +37 -0
  37. data/app/mailers/lesli_guard/application_mailer.rb +39 -0
  38. data/app/models/lesli_guard/account.rb +43 -0
  39. data/app/models/lesli_guard/application_record.rb +37 -0
  40. data/app/models/lesli_guard/dashboard/component.rb +42 -0
  41. data/app/models/lesli_guard/dashboard.rb +58 -0
  42. data/app/models/lesli_guard/descriptor/activity.rb +40 -0
  43. data/app/models/lesli_guard/descriptor/privilege.rb +40 -0
  44. data/app/models/lesli_guard/descriptor.rb +41 -0
  45. data/app/models/lesli_guard/role/activity.rb +40 -0
  46. data/app/services/lesli_guard/descriptor_privilege_service.rb +74 -0
  47. data/app/services/lesli_guard/descriptor_service.rb +152 -0
  48. data/app/services/lesli_guard/role_descriptor_service.rb +61 -0
  49. data/app/services/lesli_guard/role_service.rb +215 -0
  50. data/app/services/lesli_guard/user_service.rb +305 -0
  51. data/app/views/lesli_guard/accounts/_account.html.erb +2 -0
  52. data/app/views/lesli_guard/accounts/_form.html.erb +17 -0
  53. data/app/views/lesli_guard/accounts/edit.html.erb +10 -0
  54. data/app/views/lesli_guard/accounts/index.html.erb +14 -0
  55. data/app/views/lesli_guard/accounts/new.html.erb +9 -0
  56. data/app/views/lesli_guard/accounts/show.html.erb +10 -0
  57. data/app/views/lesli_guard/dashboards/show.html.erb +1 -0
  58. data/app/views/lesli_guard/descriptor/activities/_form.html.erb +32 -0
  59. data/app/views/lesli_guard/descriptor/activities/edit.html.erb +34 -0
  60. data/app/views/lesli_guard/descriptor/activities/index.html.erb +34 -0
  61. data/app/views/lesli_guard/descriptor/activities/new.html.erb +34 -0
  62. data/app/views/lesli_guard/descriptor/activities/show.html.erb +34 -0
  63. data/app/views/lesli_guard/descriptor/privileges/_form.html.erb +32 -0
  64. data/app/views/lesli_guard/descriptor/privileges/edit.html.erb +34 -0
  65. data/app/views/lesli_guard/descriptor/privileges/index.html.erb +34 -0
  66. data/app/views/lesli_guard/descriptor/privileges/new.html.erb +34 -0
  67. data/app/views/lesli_guard/descriptor/privileges/show.html.erb +34 -0
  68. data/app/views/lesli_guard/descriptors/_form.html.erb +32 -0
  69. data/app/views/lesli_guard/descriptors/edit.html.erb +34 -0
  70. data/app/views/lesli_guard/descriptors/index.html.erb +34 -0
  71. data/app/views/lesli_guard/descriptors/new.html.erb +34 -0
  72. data/app/views/lesli_guard/descriptors/show.html.erb +34 -0
  73. data/app/views/lesli_guard/partials/_engine-navigation.html.erb +38 -0
  74. data/app/views/lesli_guard/role/activities/_form.html.erb +32 -0
  75. data/app/views/lesli_guard/role/activities/edit.html.erb +34 -0
  76. data/app/views/lesli_guard/role/activities/index.html.erb +34 -0
  77. data/app/views/lesli_guard/role/activities/new.html.erb +34 -0
  78. data/app/views/lesli_guard/role/activities/show.html.erb +34 -0
  79. data/app/views/lesli_guard/role/descriptors/_form.html.erb +32 -0
  80. data/app/views/lesli_guard/role/descriptors/edit.html.erb +34 -0
  81. data/app/views/lesli_guard/role/descriptors/index.html.erb +34 -0
  82. data/app/views/lesli_guard/role/descriptors/new.html.erb +34 -0
  83. data/app/views/lesli_guard/role/descriptors/show.html.erb +34 -0
  84. data/app/views/lesli_guard/role/privileges/_form.html.erb +32 -0
  85. data/app/views/lesli_guard/role/privileges/edit.html.erb +34 -0
  86. data/app/views/lesli_guard/role/privileges/index.html.erb +34 -0
  87. data/app/views/lesli_guard/role/privileges/new.html.erb +34 -0
  88. data/app/views/lesli_guard/role/privileges/show.html.erb +34 -0
  89. data/app/views/lesli_guard/roles/edit.html.erb +34 -0
  90. data/app/views/lesli_guard/roles/index.html.erb +34 -0
  91. data/app/views/lesli_guard/roles/new.html.erb +34 -0
  92. data/app/views/lesli_guard/roles/show.html.erb +34 -0
  93. data/app/views/lesli_guard/users/edit.html.erb +10 -0
  94. data/app/views/lesli_guard/users/index.html.erb +34 -0
  95. data/app/views/lesli_guard/users/new.html.erb +34 -0
  96. data/app/views/lesli_guard/users/show.html.erb +1 -0
  97. data/config/locales/translations.en.yml +43 -0
  98. data/config/locales/translations.es.yml +43 -0
  99. data/config/routes.rb +90 -0
  100. data/db/migrate/v1/0801000110_create_lesli_guard_accounts.rb +42 -0
  101. data/db/migrate/v1/0801050110_create_lesli_guard_dashboards.rb +51 -0
  102. data/db/migrate/v1/0801050210_create_lesli_guard_dashboard_components.rb +53 -0
  103. data/lib/lesli_guard/engine.rb +18 -0
  104. data/lib/lesli_guard/version.rb +4 -0
  105. data/lib/lesli_guard.rb +6 -0
  106. data/lib/tasks/lesli_guard_tasks.rake +50 -0
  107. data/lib/vue/application.js +112 -0
  108. data/lib/vue/apps/descriptors/components/form.vue +136 -0
  109. data/lib/vue/apps/descriptors/edit.vue +83 -0
  110. data/lib/vue/apps/descriptors/index.vue +113 -0
  111. data/lib/vue/apps/descriptors/new.vue +69 -0
  112. data/lib/vue/apps/descriptors/show.vue +233 -0
  113. data/lib/vue/apps/roles/components/descriptors.vue +81 -0
  114. data/lib/vue/apps/roles/components/form.vue +253 -0
  115. data/lib/vue/apps/roles/components/privilegeCustom.vue +86 -0
  116. data/lib/vue/apps/roles/components/privilegeStandard.vue +196 -0
  117. data/lib/vue/apps/roles/edit.vue +118 -0
  118. data/lib/vue/apps/roles/index.vue +168 -0
  119. data/lib/vue/apps/roles/logs.vue +110 -0
  120. data/lib/vue/apps/roles/new.vue +86 -0
  121. data/lib/vue/apps/roles/show.vue +109 -0
  122. data/lib/vue/apps/users/components/information-card.vue +107 -0
  123. data/lib/vue/apps/users/components/information-form.vue +176 -0
  124. data/lib/vue/apps/users/components/integrations-information.vue +61 -0
  125. data/lib/vue/apps/users/components/management-roles.vue +107 -0
  126. data/lib/vue/apps/users/components/management-security.vue +113 -0
  127. data/lib/vue/apps/users/components/management-sessions.vue +101 -0
  128. data/lib/vue/apps/users/components/management-settings.vue +93 -0
  129. data/lib/vue/apps/users/index.vue +207 -0
  130. data/lib/vue/apps/users/new.vue +181 -0
  131. data/lib/vue/apps/users/show.vue +131 -0
  132. data/lib/vue/stores/descriptor.js +117 -0
  133. data/lib/vue/stores/descriptors.js +156 -0
  134. data/lib/vue/stores/role.js +203 -0
  135. data/lib/vue/stores/roles.js +58 -0
  136. data/lib/vue/stores/translations.json +98 -0
  137. data/lib/vue/stores/user.js +331 -0
  138. data/lib/vue/stores/users.js +176 -0
  139. data/license +674 -0
  140. data/readme.md +76 -0
  141. metadata +199 -0
@@ -0,0 +1,71 @@
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 LesliGuard
34
+ class User::SessionsController < ApplicationController
35
+ before_action :set_user_session, only: [:destroy]
36
+
37
+ # GET /user/sessions
38
+ def index
39
+ respond_to do |format|
40
+ format.html {}
41
+ format.json do
42
+ return respond_with_pagination(UserService.new(current_user, query).sessions(session[:user_session_id]))
43
+ end
44
+ end
45
+ end
46
+
47
+ # DELETE /user/sessions/1
48
+ def destroy
49
+ return respond_with_not_found unless @user_session
50
+
51
+ if @user_session.delete
52
+ current_user.logs.create({title: "close_session",description: "by_user: " + current_user.email})
53
+ respond_with_successful
54
+ else
55
+ respond_with_error(@user_session.errors.full_messages.to_sentence)
56
+ end
57
+ end
58
+
59
+ private
60
+
61
+ # Use callbacks to share common setup or constraints between actions.
62
+ def set_user_session
63
+ @user_session = User::Session.find_by(id: params[:id])
64
+ end
65
+
66
+ # Only allow a trusted parameter "white list" through.
67
+ def user_session_params
68
+ params.require(:user_session).permit(:id,)
69
+ end
70
+ end
71
+ end
@@ -0,0 +1,206 @@
1
+ module LesliGuard
2
+ class UsersController < Lesli::ApplicationLesliController
3
+ before_action :set_user, only: [
4
+ :show,
5
+ :update,
6
+ :destroy,
7
+ :requestpassword,
8
+ :passwordreset,
9
+ :revokeaccess,
10
+ :logout
11
+ ]
12
+
13
+ # GET /users/list
14
+ def list
15
+ respond_to do |format|
16
+ format.json {
17
+ respond_with_successful(UserService.new("current_user").list(query, params))
18
+ }
19
+ end
20
+ end
21
+
22
+ # GET /users
23
+ def index
24
+ respond_to do |format|
25
+ format.html
26
+ format.json {
27
+ return respond_with_pagination(UserService.new(current_user, query).index(params))
28
+ }
29
+ end
30
+ end
31
+
32
+ def show
33
+ respond_to do |format|
34
+ format.html
35
+ format.json {
36
+ return respond_with_not_found unless @user.found?
37
+ return respond_with_successful(@user.show)
38
+ }
39
+ end
40
+ end
41
+
42
+ def create
43
+ user = UserService.new(current_user).create(user_params)
44
+ if user.successful?
45
+ respond_with_successful(user.result)
46
+ else
47
+ respond_with_error("Error creating user", user.errors)
48
+ end
49
+ end
50
+
51
+ def update
52
+
53
+ # check if the user trully exists
54
+ return respond_with_not_found unless @user.found?
55
+
56
+ # update the user information
57
+ @user.update(user_params)
58
+
59
+ # check saved
60
+ if @user.successful?
61
+ respond_with_successful(@user.result)
62
+ else
63
+ respond_with_error(@user.errors)
64
+ end
65
+ end
66
+
67
+ def destroy
68
+ return respond_with_not_found unless @user
69
+
70
+ # get the user found in the UserServices
71
+ user = @user.result
72
+
73
+ if user.delete
74
+ current_user.logs.create({ title: "deleted_user", description: "by_user_id: #{ current_user.email }" })
75
+ respond_with_successful()
76
+ else
77
+ respond_with_error(user.errors.full_messages.to_sentence)
78
+ end
79
+ end
80
+
81
+ # Force the user to update his password
82
+ def requestpassword
83
+ if @user.request_password
84
+ respond_with_successful
85
+ else
86
+ respond_with_error
87
+ end
88
+ end
89
+
90
+ # Reset password (generate random)
91
+ def passwordreset
92
+
93
+ pass = @user.password_reset
94
+
95
+ if pass
96
+ respond_with_successful(pass)
97
+ else
98
+ respond_with_error
99
+ end
100
+ end
101
+
102
+ # this method is going to close all the open user sessions
103
+ def logout
104
+ if @user.logout
105
+ respond_with_successful
106
+ else
107
+ respond_with_error
108
+ end
109
+ end
110
+
111
+ # Remove all user access
112
+ def revokeaccess
113
+ if @user.revoke_access
114
+ respond_with_successful
115
+ else
116
+ respond_with_error
117
+ end
118
+ end
119
+
120
+ def become
121
+
122
+ # always should be disabled
123
+ if Rails.configuration.lesli.dig(:security, :enable_becoming) != true
124
+ return respond_with_unauthorized
125
+ end
126
+
127
+ # Allow only sysadmin to become as user
128
+ return respond_with_unauthorized if current_user.email != Rails.application.config.lesli.dig(:account, :user, :email) # sysadmin user
129
+
130
+ # Search for desire user
131
+ becoming_user = User.find(params[:id])
132
+
133
+ # Return an error if user does not exist
134
+ return respond_with_error I18n.t("core.shared.messages_warning_user_not_found") if becoming_user.blank?
135
+
136
+ # Extrictly save a log when becoming
137
+ current_user.activities.create!({
138
+ users_id: becoming_user.id,
139
+ owner_id: current_user.id,
140
+ description: "#{current_user.full_name} -> #{becoming_user.full_name}",
141
+ category: "action_become"
142
+ })
143
+
144
+ # Sign in as the becoming user
145
+ sign_in(:user, becoming_user)
146
+
147
+ # Create a new session for the becoming user
148
+ becoming_session = becoming_user.sessions.create({
149
+ :user_agent => get_user_agent,
150
+ :user_remote => request.remote_ip,
151
+ :session_source => "become_session",
152
+ :last_used_at => LC::Date.now,
153
+ :expiration_at => 60.minutes.from_now
154
+ })
155
+
156
+ # assign the session of the becomer user to the becoming user
157
+ session[:user_session_id] = becoming_session[:id]
158
+
159
+ # Response successful
160
+ respond_with_successful([current_user, becoming_user])
161
+
162
+ end
163
+
164
+ def options
165
+ respond_with_successful({
166
+ #regions: current_user.account.locations.where(level: "region"),
167
+ salutations: User::Detail.salutations.map {|k, v| {value: k, text: v}},
168
+ locales: Rails.application.config.lesli.dig(:configuration, :locales_available),
169
+ mfa_methods: Rails.application.config.lesli.dig(:configuration, :mfa_methods)
170
+ })
171
+ end
172
+
173
+ private
174
+
175
+ # @return [void]
176
+ # @description Sets the requested user based on the current_users's account
177
+ # @example
178
+ # # Executing this method from a controller action:
179
+ # set_user
180
+ # puts @user
181
+ # # This will either display nil or an instance of Account::User
182
+ def set_user
183
+ @user = UserService.new(current_user).find(params[:id])
184
+ end
185
+
186
+ def user_params
187
+ params.require(:user).permit(
188
+ :active,
189
+ :email,
190
+ :alias,
191
+ :roles_id,
192
+ :first_name,
193
+ :last_name,
194
+ :telephone,
195
+ detail_attributes: [
196
+ :title,
197
+ :salutation,
198
+ :address,
199
+ :work_city,
200
+ :work_region,
201
+ :work_address
202
+ ]
203
+ )
204
+ end
205
+ end
206
+ end
@@ -0,0 +1,4 @@
1
+ module LesliGuard
2
+ module AccountsHelper
3
+ end
4
+ end
@@ -0,0 +1,4 @@
1
+ module LesliGuard
2
+ module ApplicationHelper
3
+ end
4
+ end
@@ -0,0 +1,4 @@
1
+ module LesliGuard
2
+ module DashboardsHelper
3
+ end
4
+ end
@@ -0,0 +1,4 @@
1
+ module LesliGuard
2
+ module Descriptor::ActivitiesHelper
3
+ end
4
+ end
@@ -0,0 +1,4 @@
1
+ module LesliGuard
2
+ module Descriptor::PrivilegesHelper
3
+ end
4
+ end
@@ -0,0 +1,4 @@
1
+ module LesliGuard
2
+ module DescriptorsHelper
3
+ end
4
+ end
@@ -0,0 +1,4 @@
1
+ module LesliGuard
2
+ module Role::ActivitiesHelper
3
+ end
4
+ end
@@ -0,0 +1,4 @@
1
+ module LesliGuard
2
+ module Role::DescriptorsHelper
3
+ end
4
+ end
@@ -0,0 +1,4 @@
1
+ module LesliGuard
2
+ module Role::PrivilegesHelper
3
+ end
4
+ end
@@ -0,0 +1,4 @@
1
+ module LesliGuard
2
+ module RolesHelper
3
+ end
4
+ 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 LesliGuard
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 LesliGuard
35
+ class ApplicationMailer < ActionMailer::Base
36
+ default from: "from@example.com"
37
+ layout "mailer"
38
+ end
39
+ end
@@ -0,0 +1,43 @@
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.dev
27
+ @license GPLv3 http://www.gnu.org/licenses/gpl-3.0.en.html
28
+
29
+ // · ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~
30
+ // ·
31
+ =end
32
+
33
+ module LesliGuard
34
+ class Account < ApplicationRecord
35
+ belongs_to :account, class_name: "Lesli::Account"
36
+
37
+ after_create :initialize_account
38
+
39
+ def initialize_account
40
+ Dashboard.initialize_account(self)
41
+ end
42
+ end
43
+ 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
+ =end
32
+
33
+ module LesliGuard
34
+ class ApplicationRecord < ActiveRecord::Base
35
+ self.abstract_class = true
36
+ end
37
+ end
@@ -0,0 +1,42 @@
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 LesliGuard
34
+ class Dashboard::Component < ApplicationRecord
35
+
36
+ belongs_to :dashboard, inverse_of: :components
37
+
38
+ def self.component_ids
39
+ ["guard-users"]
40
+ end
41
+ end
42
+ end
@@ -0,0 +1,58 @@
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 LesliGuard
34
+ class Dashboard < Lesli::Shared::Dashboard
35
+ self.table_name = "lesli_guard_dashboards"
36
+ belongs_to :account
37
+
38
+ has_many :components, inverse_of: :dashboard, autosave: true, dependent: :destroy
39
+ accepts_nested_attributes_for :components, allow_destroy: true
40
+
41
+ def self.initialize_account(account)
42
+ self.create_with(
43
+ default: true,
44
+ main: false,
45
+ components_attributes: [{
46
+ name: "Users",
47
+ component_id: "guard-users",
48
+ layout: 3,
49
+ query_configuration: {},
50
+ custom_configuration: {}
51
+ }]
52
+ ).find_or_create_by!(
53
+ account: account,
54
+ name: "Default Dashboard"
55
+ )
56
+ end
57
+ end
58
+ end
@@ -0,0 +1,40 @@
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 LesliGuard
35
+ class Descriptor::Activity < ApplicationRecord
36
+
37
+ belongs_to :descriptor
38
+
39
+ end
40
+ end
@@ -0,0 +1,40 @@
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 LesliGuard
35
+ class Descriptor::Privilege < ApplicationRecord
36
+
37
+ belongs_to :descriptor
38
+
39
+ end
40
+ end