lesli 5.0.19 → 5.0.21
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 +4 -4
- data/app/assets/images/lesli/brand/register-background.jpg +0 -0
- data/app/assets/stylesheets/lesli/application.css +1 -0
- data/app/helpers/lesli/navigation_helper.rb +6 -0
- data/app/interfaces/lesli/responder_interface.rb +35 -19
- data/app/models/concerns/lesli/account_initializer.rb +79 -0
- data/app/models/concerns/lesli/user_extensions.rb +133 -0
- data/app/models/concerns/lesli/user_security.rb +220 -0
- data/app/models/lesli/role/action.rb +3 -2
- data/app/models/lesli/shared/dashboard.rb +2 -2
- data/app/models/lesli/user/session.rb +1 -1
- data/app/models/lesli/user.rb +15 -15
- data/app/operators/lesli/role_operator.rb +9 -4
- data/app/services/lesli/role/action_service.rb +2 -3
- data/app/services/lesli/role_service.rb +3 -3
- data/app/views/lesli/abouts/welcome.html.erb +8 -5
- data/app/views/lesli/apps/show.html.erb +21 -33
- data/app/views/lesli/errors/not_found.html.erb +32 -0
- data/app/views/lesli/errors/unauthorized.html.erb +48 -0
- data/app/views/lesli/layouts/application-devise.html.erb +2 -2
- data/app/views/lesli/layouts/application-lesli.html.erb +1 -2
- data/app/views/lesli/partials/_application-analytics.html.erb +2 -2
- data/app/views/lesli/partials/_application-data.html.erb +0 -1
- data/app/views/lesli/partials/_application-head.html.erb +4 -4
- data/app/views/lesli/partials/_application-lesli-header.html.erb +47 -67
- data/app/views/lesli/partials/_application-lesli-navigation.html.erb +23 -5
- data/config/importmap.rb +0 -10
- data/config/initializers/devise_rails_8_patch.rb +8 -0
- data/config/initializers/lesli.rb +27 -23
- data/db/migrate/v1/0000120310_create_lesli_role_privileges.rb +2 -2
- data/db/seed/accounts.rb +1 -1
- data/db/seed/users.rb +6 -4
- data/db/seeds.rb +6 -6
- data/lib/lesli/engine.rb +0 -14
- data/lib/lesli/routing.rb +1 -1
- data/lib/lesli/version.rb +2 -2
- data/lib/rspec/testers/request.rb +15 -6
- data/lib/scss/_apps.scss +93 -0
- data/lib/scss/application.scss +34 -0
- data/lib/tasks/lesli/controllers.rake +1 -1
- data/lib/tasks/lesli/db.rake +27 -27
- data/lib/tasks/lesli_tasks.rake +3 -0
- data/readme.md +9 -10
- metadata +33 -13
- data/app/models/concerns/account_initializer.rb +0 -83
- data/app/models/concerns/user_extensions.rb +0 -152
- data/app/models/concerns/user_security.rb +0 -276
- data/app/operators/lesli/user_registration_operator.rb +0 -122
- /data/app/models/concerns/{user_activities.rb → lesli/user_activities.rb} +0 -0
@@ -1,122 +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
|
-
|
32
|
-
=end
|
33
|
-
|
34
|
-
module Lesli
|
35
|
-
class UserRegistrationOperator < Lesli::ApplicationLesliService
|
36
|
-
|
37
|
-
def initialize(current_user)
|
38
|
-
@resource = current_user
|
39
|
-
@current_user = current_user
|
40
|
-
end
|
41
|
-
|
42
|
-
def confirm
|
43
|
-
|
44
|
-
if current_user.blank?
|
45
|
-
failures.push(I18n.t("core.shared.messages_warning_user_not_found"))
|
46
|
-
return self
|
47
|
-
end
|
48
|
-
|
49
|
-
# confirm the user
|
50
|
-
current_user.confirm
|
51
|
-
|
52
|
-
# force token deletion so we are sure nobody will be able to use the token again
|
53
|
-
resource.update(confirmation_token: nil)
|
54
|
-
|
55
|
-
# send a welcome email to user as is confirmed
|
56
|
-
#UserMailer.with(user: resource).welcome.deliver_later
|
57
|
-
|
58
|
-
# initialize user dependencies
|
59
|
-
current_user.after_confirmation_user
|
60
|
-
|
61
|
-
end
|
62
|
-
|
63
|
-
def create_account
|
64
|
-
|
65
|
-
if resource.blank?
|
66
|
-
failures.push(I18n.t("core.shared.messages_warning_user_not_found"))
|
67
|
-
return self
|
68
|
-
end
|
69
|
-
|
70
|
-
if resource.account
|
71
|
-
failures.push(I18n.t("core.users.messages_info_user_already_belongs_to_account"))
|
72
|
-
return self
|
73
|
-
end
|
74
|
-
|
75
|
-
# check if instance is for multi-account
|
76
|
-
allow_multiaccount = Lesli.config.security.dig(:allow_multiaccount)
|
77
|
-
|
78
|
-
# create new account for the new user only if multi-account is allowed
|
79
|
-
if allow_multiaccount === true
|
80
|
-
account = Account.create!({
|
81
|
-
user: resource, # set user as owner of his just created account
|
82
|
-
name: "Lesli", # temporary company name
|
83
|
-
email: resource.email,
|
84
|
-
status: :active # account is active due user already confirmed his email
|
85
|
-
})
|
86
|
-
end
|
87
|
-
|
88
|
-
# if multi-account is not allowed user belongs to the first account in instance
|
89
|
-
if allow_multiaccount === false
|
90
|
-
account = Account.first
|
91
|
-
end
|
92
|
-
|
93
|
-
# add user to his own account
|
94
|
-
resource.account = account
|
95
|
-
|
96
|
-
# add owner role to user only if multi-account is allowed
|
97
|
-
if allow_multiaccount == true
|
98
|
-
#resource.powers.create({ role: account.roles.find_by(name: "owner") })
|
99
|
-
end
|
100
|
-
|
101
|
-
# add profile role to user only if multi-account is allowed
|
102
|
-
if allow_multiaccount == false
|
103
|
-
# Assigning default role if defined in account settings
|
104
|
-
# Otherwise, the default role is "limited"
|
105
|
-
#default_role_id = account.settings.find_by(:name => "default_role_id")&.value
|
106
|
-
|
107
|
-
if default_role_id.present?
|
108
|
-
resource.user_roles.create({ role: account.roles.find_by(:id => default_role_id)})
|
109
|
-
else
|
110
|
-
resource.user_roles.create({ role: account.roles.find_by(name: "limited") })
|
111
|
-
end
|
112
|
-
end
|
113
|
-
|
114
|
-
# update user :)
|
115
|
-
resource.save
|
116
|
-
|
117
|
-
# initialize user dependencies
|
118
|
-
resource.after_account_assignation
|
119
|
-
|
120
|
-
end
|
121
|
-
end
|
122
|
-
end
|
File without changes
|