lesli 5.0.3 → 5.0.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (71) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/config/lesli_manifest.js +2 -1
  3. data/app/assets/javascripts/lesli/users/confirmations.js +32 -0
  4. data/app/assets/javascripts/lesli/users/passwords.js +3 -3
  5. data/app/assets/javascripts/lesli/users/registrations.js +2 -2
  6. data/app/assets/javascripts/lesli/users/sessions.js +2 -2
  7. data/app/assets/stylesheets/lesli/users/confirmations.scss +28 -6
  8. data/app/controllers/lesli/interfaces/application/authorization.rb +2 -2
  9. data/app/controllers/lesli/interfaces/application/logger.rb +14 -38
  10. data/app/controllers/lesli/roles_controller.rb +3 -1
  11. data/app/controllers/users/confirmations_controller.rb +63 -27
  12. data/app/controllers/users/passwords_controller.rb +70 -30
  13. data/app/controllers/users/sessions_controller.rb +2 -4
  14. data/app/lib/lesli/system.rb +13 -5
  15. data/app/mailers/lesli/application_lesli_mailer.rb +8 -19
  16. data/app/mailers/lesli/devise_mailer.rb +29 -3
  17. data/app/models/concerns/account_initializer.rb +91 -0
  18. data/app/models/concerns/{user_guard.rb → user_security.rb} +7 -8
  19. data/app/models/lesli/account.rb +8 -26
  20. data/app/models/lesli/application_lesli_record.rb +1 -0
  21. data/app/models/lesli/descriptor/privilege.rb +38 -0
  22. data/app/models/lesli/descriptor.rb +18 -1
  23. data/app/models/lesli/role/power.rb +70 -0
  24. data/app/models/lesli/role/privilege.rb +38 -0
  25. data/app/models/lesli/role.rb +20 -15
  26. data/app/models/lesli/user/{role.rb → power.rb} +1 -1
  27. data/app/{services/lesli/role_service.rb → models/lesli/user/setting.rb} +10 -9
  28. data/app/models/lesli/user.rb +11 -20
  29. data/app/operators/lesli/descriptor_privilege_operator.rb +75 -0
  30. data/app/operators/lesli/role_power_operator.rb +108 -0
  31. data/app/operators/lesli/user_registration_operator.rb +121 -0
  32. data/app/services/lesli/user_service.rb +2 -4
  33. data/app/services/lesli/{user/session_service.rb → user_session_service.rb} +11 -4
  34. data/app/views/devise/confirmations/new.html.erb +0 -14
  35. data/app/views/devise/confirmations/show.html.erb +63 -0
  36. data/app/views/devise/passwords/edit.html.erb +78 -24
  37. data/app/views/devise/passwords/new.html.erb +1 -2
  38. data/app/views/lesli/emails/devise_mailer/confirmation_instructions.html.erb +1 -1
  39. data/app/views/lesli/emails/devise_mailer/reset_password_instructions.html.erb +23 -0
  40. data/app/views/lesli/partials/_application-lesli-header.html.erb +3 -1
  41. data/config/initializers/devise.rb +2 -0
  42. data/db/migrate/v1.0/0010000110_create_lesli_accounts.rb +2 -0
  43. data/db/{tables/0010001010_create_account_settings.rb → migrate/v1.0/0010001010_create_lesli_account_settings.rb} +5 -5
  44. data/db/{tables/0010003110_create_user_settings.rb → migrate/v1.0/0010003110_create_lesli_user_settings.rb} +4 -4
  45. data/db/migrate/v1.0/0010003210_create_lesli_user_sessions.rb +6 -2
  46. data/db/migrate/v1.0/{0010003410_create_lesli_user_roles.rb → 0010003410_create_lesli_user_powers.rb} +4 -4
  47. data/db/migrate/v1.0/0010005010_create_lesli_descriptors.rb +1 -1
  48. data/db/migrate/v1.0/{0010003910_create_lesli_user_agents.rb → 0010005510_create_lesli_role_powers.rb} +7 -9
  49. data/db/{tables/0010005710_create_role_privileges.rb → migrate/v1.0/0010005710_create_lesli_role_privileges.rb} +6 -6
  50. data/db/seed/development/users.rb +4 -4
  51. data/db/seed/tools.rb +4 -4
  52. data/lib/lesli/engine.rb +33 -10
  53. data/lib/lesli/version.rb +1 -1
  54. data/lib/sass/lesli/bulma/loader.scss +3 -0
  55. data/lib/sass/lesli/pages/devise-simple.scss +2 -1
  56. data/lib/tasks/lesli/controllers.rake +3 -6
  57. data/lib/tasks/lesli/db.rake +11 -1
  58. data/lib/tasks/lesli/role.rake +54 -0
  59. data/lib/vue/application.js +9 -2
  60. data/lib/vue/devise/passwords.js +3 -3
  61. data/lib/vue/layouts/application-header.vue +10 -3
  62. data/lib/webpack/core.js +2 -1
  63. data/readme.md +23 -7
  64. metadata +22 -18
  65. data/app/models/concerns/account_engines.rb +0 -249
  66. data/app/models/concerns/user_polyfill.rb +0 -134
  67. data/config/locales/translations.en.yml +0 -7
  68. data/config/locales/translations.es.yml +0 -7
  69. data/db/migrate/v1.0/0010001510_create_lesli_account_requests.rb +0 -45
  70. data/db/migrate/v1.0/0010003810_create_lesli_user_requests.rb +0 -44
  71. data/db/tables/0010005510_create_role_descriptors.rb +0 -44
@@ -1,249 +0,0 @@
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 AccountEngines
34
- extend ActiveSupport::Concern
35
-
36
-
37
- # initialize engines for new accounts
38
- def initialize_engines
39
-
40
- if defined? CloudDispatcher
41
- if self.dispatcher.blank?
42
- self.dispatcher = CloudDispatcher::Account.new
43
- self.dispatcher.account = self
44
- self.dispatcher.save!
45
- end
46
- end
47
-
48
- if defined? CloudKb
49
- if self.kb.blank?
50
- self.kb = CloudKb::Account.new
51
- self.kb.account = self
52
- self.kb.save!
53
- end
54
- end
55
-
56
- if defined? CloudOne
57
- if self.one.blank?
58
- self.one = CloudOne::Account.new
59
- self.one.account = self
60
- self.one.save!
61
- end
62
- end
63
-
64
- if defined? CloudTeam
65
- if self.team.blank?
66
- self.team = CloudTeam::Account.new
67
- self.team.account = self
68
- self.team.save!
69
- end
70
- end
71
-
72
- if defined? CloudBell
73
- if self.bell.blank?
74
- self.bell = CloudBell::Account.new
75
- self.bell.account = self
76
- self.bell.save!
77
- end
78
- end
79
-
80
- if defined? CloudDriver
81
- if self.driver.blank?
82
- self.driver = CloudDriver::Account.new
83
- self.driver.account = self
84
- self.driver.save!
85
- end
86
- end
87
-
88
- if defined? CloudFocus
89
- if self.focus.blank?
90
- self.focus = CloudFocus::Account.new
91
- self.focus.account = self
92
- self.focus.save!
93
- end
94
- end
95
-
96
- if defined? CloudHelp
97
- if self.help.blank?
98
- self.help = CloudHelp::Account.new
99
- self.help.account = self
100
- self.help.save!
101
- end
102
- end
103
-
104
- if defined? CloudMailer
105
- if self.mailer.blank?
106
- self.mailer = CloudMailer::Account.new
107
- self.mailer.account = self
108
- self.mailer.save!
109
- end
110
- end
111
-
112
- if defined? CloudText
113
- if self.text.blank?
114
- self.text = CloudText::Account.new
115
- self.text.account = self
116
- self.text.save!
117
- end
118
- end
119
-
120
- if defined? CloudTalk
121
- if self.talk.blank?
122
- self.talk = CloudTalk::Account.new
123
- self.talk.account = self
124
- self.talk.save!
125
- end
126
- end
127
-
128
- if defined? CloudStorage
129
- if self.storage.blank?
130
- self.storage = CloudStorage::Account.new
131
- self.storage.account = self
132
- self.storage.save!
133
- end
134
- end
135
-
136
- if defined? CloudBooks
137
- if self.books.blank?
138
- self.books = CloudBooks::Account.new
139
- self.books.account = self
140
- self.books.save!
141
- end
142
- end
143
-
144
- if defined? CloudHouse
145
- if self.house.blank?
146
- self.house = CloudHouse::Account.new
147
- self.house.account = self
148
- self.house.save!
149
- end
150
- end
151
-
152
- if defined? CloudAudit
153
- if self.audit.blank?
154
- self.audit = CloudAudit::Account.new
155
- self.audit.account = self
156
- self.audit.save!
157
- end
158
- end
159
-
160
- if defined? CloudThings
161
- if self.things.blank?
162
- self.things = CloudThings::Account.new
163
- self.things.account = self
164
- self.things.save!
165
- end
166
- end
167
-
168
- if defined? CloudProposal
169
- if self.proposal.blank?
170
- self.proposal = CloudProposal::Account.new
171
- self.proposal.account = self
172
- self.proposal.save!
173
- end
174
- end
175
-
176
- if defined? CloudRealty
177
- if self.realty.blank?
178
- self.realty = CloudRealty::Account.new
179
- self.realty.account = self
180
- self.realty.save!
181
- end
182
- end
183
-
184
- if defined? CloudLesli
185
- if self.lesli.blank?
186
- self.lesli = CloudLesli::Account.new
187
- self.lesli.account = self
188
- self.lesli.save!
189
- end
190
- end
191
-
192
- if defined? CloudShared
193
- if self.shared.blank?
194
- self.shared = CloudShared::Account.new
195
- self.shared.account = self
196
- self.shared.save!
197
- end
198
- end
199
-
200
- if defined? CloudPortal
201
- if self.portal.blank?
202
- self.portal = CloudPortal::Account.new
203
- self.portal.account = self
204
- self.portal.save!
205
- end
206
- end
207
-
208
- if defined? CloudWork
209
- if self.work.blank?
210
- self.work = CloudWork::Account.new
211
- self.work.account = self
212
- self.work.save!
213
- end
214
- end
215
-
216
- if defined? CloudWord
217
- if self.word.blank?
218
- self.word = CloudWord::Account.new
219
- self.word.account = self
220
- self.word.save!
221
- end
222
- end
223
-
224
- if defined? CloudSocial
225
- if self.social.blank?
226
- self.social = CloudSocial::Account.new
227
- self.social.account = self
228
- self.social.save!
229
- end
230
- end
231
-
232
- if defined? CloudScraper
233
- if self.scraper.blank?
234
- self.scraper = CloudScraper::Account.new
235
- self.scraper.account = self
236
- self.scraper.save!
237
- end
238
- end
239
-
240
- if defined? CloudTime
241
- if self.time.blank?
242
- self.time = CloudTime::Account.new
243
- self.time.account = self
244
- self.time.save!
245
- end
246
- end
247
-
248
- end
249
- end
@@ -1,134 +0,0 @@
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 · Your Smart Business Assistant.
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://lesli.tech
27
- @license GPLv3 http://www.gnu.org/licenses/gpl-3.0.en.html
28
-
29
- // · ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~
30
- // ·
31
-
32
- =end
33
-
34
-
35
- # DEPRECATED METHODS
36
- # We still need to keep the definition of this methods to bring compatibility to old installations of Lesli
37
- module UserPolyfill
38
- extend ActiveSupport::Concern
39
-
40
- def has_privileges3?(controllers, actions)
41
-
42
- begin
43
-
44
- # This query fetch all the privileges actions that the user have through role descriptor assignments
45
- sql_role_privile_actions = self.role_privilege_actions
46
- .select(
47
- "status",
48
- "system_controller_actions.name as action",
49
- "system_controllers.name as controller"
50
- )
51
- .joins(system_action: [:system_controller])
52
- .where("system_controllers.name in (?)", controllers)
53
- .where("system_controller_actions.name in (?)", actions)
54
- .to_sql
55
-
56
-
57
- # This query fetch all the privileges actions that the user have through privileges actions added to the specific user
58
- sql_user_privilege_actions = self.user_privilege_actions
59
- .select(
60
- "status",
61
- "system_controller_actions.name as action",
62
- "system_controllers.name as controller"
63
- )
64
- .joins(system_action: [:system_controller])
65
- .where("system_controllers.name in (?)", controllers)
66
- .where("system_controller_actions.name in (?)", actions)
67
- .to_sql
68
-
69
-
70
- # This query is on charge of evaluate if the user have every specific privilege action
71
- # no matter if is given indirectly by role or directly to the user. Then, after getting each
72
- # specific boolean value of every privilege action, the query evalueate if is there some privilege
73
- # action on false, if there is a false then the return of the method will be false, but if every
74
- # privilege action is on true the permission is granted.
75
- # This is possible by the union of the two previous queries
76
- granted = ActiveRecord::Base.connection.exec_query("
77
- select
78
- bool_and(grouped_privileges.status) as value
79
- from (
80
- select
81
- privilege_actions.controller,
82
- privilege_actions.action,
83
- BOOL_OR(privilege_actions.status) as status
84
- from (
85
- #{sql_role_privile_actions}
86
- union
87
- #{sql_user_privilege_actions}
88
- ) AS privilege_actions
89
- group by (
90
- controller,
91
- action
92
- )
93
- ) AS grouped_privileges
94
- ")
95
- .first["value"]
96
-
97
- return false if granted.blank?
98
-
99
- return granted
100
-
101
- rescue => exception
102
-
103
- Honeybadger.notify(exception)
104
- return false
105
-
106
- end
107
-
108
- end
109
-
110
-
111
- # @return [void]
112
- # @description After creating a user, creates the necessary resources for them to access the different engines.
113
- # check role of the user
114
- def is_role? *roles
115
- LC::Debug.deprecation("Use has_roles?(role1, role2 ... rolen) instead")
116
- return has_roles?(roles)
117
- end
118
-
119
- def log_activity request_method, request_controller, request_action, request_url, description = nil
120
- LC::Debug.deprecation("Use user.activities, user.logs or log_user_comments instead")
121
- end
122
-
123
- def generate_password_token
124
- LC::Debug.deprecation("use generate_reset_password_token instead and build the email manually")
125
- end
126
-
127
- def self.send_password_reset(user)
128
- LC::Debug.deprecation("use generate_reset_password_token instead and build the email manually")
129
- end
130
-
131
- def send_welcome_email
132
- LC::Debug.deprecation("use generate_reset_password_token instead and build the email manually")
133
- end
134
- end
@@ -1,7 +0,0 @@
1
- ---
2
- :en:
3
- lesli:
4
- shared:
5
- title_lesli: ":lesli.shared.title_lesli:"
6
- users:
7
- title_users: Users
@@ -1,7 +0,0 @@
1
- ---
2
- :es:
3
- lesli:
4
- shared:
5
- title_lesli: 'Lesli en español '
6
- users:
7
- title_users: Usuarios
@@ -1,45 +0,0 @@
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 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
- class CreateLesliAccountRequests < ActiveRecord::Migration[6.0]
34
- def change
35
- create_table :lesli_account_requests do |t|
36
- t.string :request_controller
37
- t.string :request_action
38
- t.string :request_method
39
- t.integer :request_count
40
- t.date :created_at
41
- end
42
- add_reference(:lesli_account_requests, :account, foreign_key: { to_table: :lesli_accounts })
43
- add_index(:lesli_account_requests, %i[request_controller request_action created_at account_id], unique: true, name: "lesli_account_requests_index")
44
- end
45
- end
@@ -1,44 +0,0 @@
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 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
- class CreateLesliUserRequests < ActiveRecord::Migration[6.0]
34
- def change
35
- create_table :lesli_user_requests do |t|
36
- t.integer :request_count
37
- t.date :created_at
38
- t.datetime :updated_at
39
- end
40
- add_reference(:lesli_user_requests, :user, foreign_key: { to_table: :lesli_users })
41
- add_reference(:lesli_user_requests, :session, foreign_key: { to_table: :lesli_user_sessions })
42
- add_index(:lesli_user_requests, %i[created_at user_id session_id], unique: true, name: "lesli_user_requests_index")
43
- end
44
- end
@@ -1,44 +0,0 @@
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
- class CreateRoleDescriptors < ActiveRecord::Migration[7.0]
34
- def change
35
- create_table :role_descriptors do |t|
36
- t.datetime :deleted_at, index: true
37
- t.timestamps
38
- end
39
-
40
- add_reference(:role_descriptors, :user, foreign_key: { to_table: :users })
41
- add_reference(:role_descriptors, :role, foreign_key: { to_table: :roles })
42
- add_reference(:role_descriptors, :descriptor, foreign_key: { to_table: :descriptors })
43
- end
44
- end