lesli_shield 1.0.2 → 1.0.4
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/stylesheets/lesli_shield/confirmations.css +18763 -0
- data/app/assets/stylesheets/lesli_shield/devise/oauth.css +32 -0
- data/app/assets/stylesheets/lesli_shield/passwords.css +18717 -1
- data/app/assets/stylesheets/lesli_shield/registrations.css +18804 -1
- data/app/assets/stylesheets/lesli_shield/sessions.css +18804 -1
- data/app/assets/stylesheets/lesli_shield/users.css +30 -0
- data/app/controllers/lesli_shield/dashboards_controller.rb +1 -8
- data/app/controllers/lesli_shield/invites_controller.rb +80 -0
- data/app/controllers/lesli_shield/role/actions_controller.rb +32 -20
- data/app/controllers/lesli_shield/roles_controller.rb +16 -8
- data/app/controllers/lesli_shield/sessions_controller.rb +5 -8
- data/app/controllers/lesli_shield/user/roles_controller.rb +62 -0
- data/app/controllers/lesli_shield/users_controller.rb +57 -20
- data/app/controllers/users/confirmations_controller.rb +42 -8
- data/app/controllers/users/passwords_controller.rb +52 -37
- data/app/controllers/users/registrations_controller.rb +2 -8
- data/app/controllers/users/sessions_controller.rb +57 -50
- data/app/helpers/lesli_shield/invites_helper.rb +4 -0
- data/app/helpers/lesli_shield/user/roles_helper.rb +4 -0
- data/app/interfaces/lesli_shield/authorization_interface.rb +8 -2
- data/app/mailers/lesli_shield/devise_mailer.rb +98 -0
- data/app/mailers/lesli_shield/invitation.html.erb +23 -0
- data/app/models/concerns/lesli_shield/user_security.rb +222 -0
- data/app/models/lesli_shield/account.rb +1 -1
- data/app/models/lesli_shield/dashboard.rb +1 -4
- data/app/models/lesli_shield/invite.rb +24 -0
- data/{lib/vue/confirmations.js → app/models/lesli_shield/role/action.rb} +17 -10
- data/{db/migrate/v1/0801003010_create_lesli_shield_dashboards.rb → app/models/lesli_shield/role/privilege.rb} +5 -4
- data/app/models/lesli_shield/user/role.rb +8 -0
- data/app/models/lesli_shield/user/session.rb +80 -0
- data/app/services/lesli_shield/invite_service.rb +43 -0
- data/app/services/lesli_shield/role_action_service.rb +118 -0
- data/app/services/lesli_shield/role_privilege_service.rb +112 -0
- data/app/{operators/lesli_shield/user_registration_operator.rb → services/lesli_shield/user_registration_service.rb} +26 -29
- data/app/services/lesli_shield/user_session_service.rb +78 -0
- data/app/services/lesli_shield/user_validator_service.rb +221 -0
- data/app/views/devise/confirmations/show.html.erb +4 -6
- data/app/views/devise/passwords/edit.html.erb +1 -2
- data/app/views/devise/passwords/new.html.erb +1 -1
- data/app/views/devise/registrations/new.html.erb +5 -4
- data/app/views/devise/sessions/new.html.erb +3 -2
- data/app/views/devise/shared/_application-devise-simple.erb +59 -0
- data/app/views/devise/shared/_application-devise.html.erb +76 -0
- data/app/views/lesli_shield/dashboards/_component-calendar.html.erb +1 -0
- data/app/views/lesli_shield/dashboards/_component-chart-bar.html.erb +6 -0
- data/app/views/lesli_shield/dashboards/_component-chart-line.html.erb +8 -0
- data/app/views/lesli_shield/dashboards/_component-count.html.erb +1 -0
- data/app/views/lesli_shield/dashboards/_component-date.html.erb +1 -0
- data/app/views/lesli_shield/dashboards/_component-weather.html.erb +1 -0
- data/app/views/lesli_shield/invites/_form.html.erb +10 -0
- data/app/views/lesli_shield/invites/_invite.html.erb +2 -0
- data/app/views/lesli_shield/invites/edit.html.erb +12 -0
- data/app/views/lesli_shield/invites/index.html.erb +66 -0
- data/{db/migrate/v1/0801001710_create_lesli_shield_settings.rb → app/views/lesli_shield/invites/new.html.erb} +9 -10
- data/{lib/vue/apps/dashboards/components/engine-version.vue → app/views/lesli_shield/invites/show.html.erb} +26 -43
- data/app/views/lesli_shield/partials/_navigation.html.erb +2 -4
- data/app/views/lesli_shield/{roles/_form-privileges.html.erb → role/actions/_form.html.erb} +5 -30
- data/app/views/lesli_shield/role/actions/index.html.erb +14 -0
- data/app/views/lesli_shield/roles/index.html.erb +2 -6
- data/app/views/lesli_shield/roles/new.html.erb +0 -11
- data/app/views/lesli_shield/roles/show.html.erb +5 -8
- data/app/views/lesli_shield/user/roles/_form.html.erb +17 -0
- data/app/views/lesli_shield/user/roles/_role.html.erb +2 -0
- data/app/views/lesli_shield/user/roles/edit.html.erb +12 -0
- data/app/views/lesli_shield/user/roles/index.html.erb +16 -0
- data/app/views/lesli_shield/user/roles/new.html.erb +11 -0
- data/app/views/lesli_shield/user/roles/show.html.erb +10 -0
- data/app/views/lesli_shield/users/{_viewer-activities.html.erb → _activities-viewer.html.erb} +2 -4
- data/app/views/lesli_shield/users/_information-card.html.erb +3 -3
- data/app/views/lesli_shield/users/_management-privileges.html.erb +74 -0
- data/app/views/lesli_shield/users/_management-security.html.erb +5 -0
- data/app/views/lesli_shield/users/index.html.erb +3 -7
- data/app/views/lesli_shield/users/new.html.erb +5 -11
- data/app/views/lesli_shield/users/show.html.erb +7 -5
- data/config/initializers/devise.rb +305 -304
- data/config/locales/translations.en.yml +4 -1
- data/config/locales/translations.es.yml +4 -1
- data/config/locales/translations.it.yml +4 -1
- data/config/routes.rb +7 -8
- data/db/migrate/v1/0801100210_create_lesli_shield_role_actions.rb +48 -0
- data/db/migrate/v1/0801100410_create_lesli_shield_role_privileges.rb +45 -0
- data/db/migrate/v1/0801110110_create_lesli_shield_user_roles.rb +43 -0
- data/db/migrate/v1/0801111210_create_lesli_shield_user_sessions.rb +56 -0
- data/db/migrate/v1/0801120110_create_lesli_shield_invites.rb +49 -0
- data/lib/lesli_shield/engine.rb +3 -3
- data/lib/lesli_shield/router.rb +21 -0
- data/lib/lesli_shield/version.rb +2 -2
- data/lib/lesli_shield.rb +1 -1
- data/lib/scss/_devise.scss +10 -0
- data/lib/scss/confirmations.scss +24 -24
- data/lib/tasks/lesli_shield_tasks.rake +1 -1
- data/readme.md +59 -20
- metadata +69 -44
- data/app/controllers/lesli_shield/dashboard/components_controller.rb +0 -60
- data/app/models/lesli_shield/dashboard/component.rb +0 -18
- data/app/views/lesli_shield/dashboards/edit.html.erb +0 -1
- data/app/views/lesli_shield/dashboards/index.html.erb +0 -9
- data/app/views/lesli_shield/dashboards/new.html.erb +0 -1
- data/app/views/lesli_shield/dashboards/show.html.erb +0 -1
- data/app/views/lesli_shield/roles/_session.html.erb +0 -2
- data/app/views/lesli_shield/roles/edit.html.erb +0 -12
- data/app/views/lesli_shield/roles/update.turbo_stream.erb +0 -3
- data/app/views/lesli_shield/users/update.turbo_stream.erb +0 -3
- data/lib/lesli_shield/routing.rb +0 -23
- data/lib/vue/application.js +0 -83
- data/lib/vue/apps/sessions/index.vue +0 -50
- data/lib/vue/passwords.js +0 -137
- data/lib/vue/registrations.js +0 -144
- data/lib/vue/sessions.js +0 -148
- data/lib/vue/stores/sessions.js +0 -43
- data/lib/vue/stores/translations.json +0 -162
- /data/app/views/lesli_shield/roles/{_form-information.html.erb → _form.html.erb} +0 -0
- /data/db/migrate/v1/{0801120310_create_lesli_shield_user_shortcuts.rb → 0801111010_create_lesli_shield_user_shortcuts.rb} +0 -0
- /data/db/migrate/v1/{0801120410_create_lesli_shield_user_tokens.rb → 0801111110_create_lesli_shield_user_tokens.rb} +0 -0
|
@@ -1 +1,31 @@
|
|
|
1
|
+
@charset "UTF-8";
|
|
2
|
+
/*
|
|
3
|
+
Lesli
|
|
1
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
|
+
*/
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
module LesliShield
|
|
2
|
+
class InvitesController < ApplicationController
|
|
3
|
+
before_action :set_invite, only: %i[ show edit update destroy ]
|
|
4
|
+
|
|
5
|
+
# GET /invites
|
|
6
|
+
def index
|
|
7
|
+
@invites = respond_with_pagination(LesliShield::InviteService.new(current_user, query).index(params))
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
# GET /invites/1
|
|
11
|
+
def show
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
# GET /invites/new
|
|
15
|
+
def new
|
|
16
|
+
@invite = Invite.new
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
# GET /invites/1/edit
|
|
20
|
+
def edit
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
# POST /invites
|
|
24
|
+
def create
|
|
25
|
+
@invite = current_user.account.shield.invites.new(invite_params)
|
|
26
|
+
@invite.user = current_user
|
|
27
|
+
if @invite.save
|
|
28
|
+
|
|
29
|
+
log(
|
|
30
|
+
subject: @invite,
|
|
31
|
+
operation: 'invite.created',
|
|
32
|
+
description: "Invitation created successfully created for: #{@invite.email}"
|
|
33
|
+
)
|
|
34
|
+
|
|
35
|
+
success("Invite was successfully created.")
|
|
36
|
+
respond_with_lesli(
|
|
37
|
+
turbo: stream_redirection(invite_path(@invite))
|
|
38
|
+
)
|
|
39
|
+
else
|
|
40
|
+
respond_with_lesli(
|
|
41
|
+
turbo: stream_notification_danger(@invite.errors.full_messages.to_sentence)
|
|
42
|
+
)
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
# PATCH/PUT /invites/1
|
|
47
|
+
def update
|
|
48
|
+
if @invite.update(invite_params)
|
|
49
|
+
log(
|
|
50
|
+
subject: @invite,
|
|
51
|
+
description: "Invitation updated successfully"
|
|
52
|
+
)
|
|
53
|
+
respond_with_lesli(
|
|
54
|
+
:turbo => stream_notification_success("Invite was successfully updated.")
|
|
55
|
+
)
|
|
56
|
+
else
|
|
57
|
+
respond_with_lesli(
|
|
58
|
+
:turbo => stream_notification_danger(@invite.errors.full_messages.to_sentence)
|
|
59
|
+
)
|
|
60
|
+
end
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
# DELETE /invites/1
|
|
64
|
+
def destroy
|
|
65
|
+
@invite.destroy!
|
|
66
|
+
redirect_to invites_path, notice: "Invite was successfully destroyed.", status: :see_other
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
private
|
|
70
|
+
# Use callbacks to share common setup or constraints between actions.
|
|
71
|
+
def set_invite
|
|
72
|
+
@invite = Invite.find(params.expect(:id))
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
# Only allow a list of trusted parameters through.
|
|
76
|
+
def invite_params
|
|
77
|
+
params.require(:invite).permit(:email, :full_name, :telephone, :notes, :status)
|
|
78
|
+
end
|
|
79
|
+
end
|
|
80
|
+
end
|
|
@@ -1,40 +1,52 @@
|
|
|
1
1
|
module LesliShield
|
|
2
2
|
class Role::ActionsController < ApplicationController
|
|
3
|
-
before_action :
|
|
3
|
+
before_action :set_role, only: %i[index update destroy]
|
|
4
|
+
before_action :set_role_action, only: %i[update destroy]
|
|
5
|
+
|
|
6
|
+
def index
|
|
7
|
+
@role_actions = RoleActionService.new(current_user, query).index(@role.id)
|
|
8
|
+
end
|
|
4
9
|
|
|
5
10
|
def update
|
|
6
|
-
# check saved
|
|
7
11
|
if @role_action.result.recover
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
@role_actions = RoleActionService.new(current_user, query).index(@role.id)
|
|
13
|
+
respond_with_lesli(
|
|
14
|
+
:turbo => [
|
|
15
|
+
stream_notification_success("Role privileges added successfully!"),
|
|
16
|
+
turbo_stream.replace('shield-role-actions-form', partial: 'lesli_shield/role/actions/form')
|
|
17
|
+
]
|
|
18
|
+
)
|
|
14
19
|
else
|
|
15
|
-
|
|
20
|
+
respond_with_lesli(
|
|
21
|
+
:turbo => stream_notification_danger(@role_action.errors_as_sentence)
|
|
22
|
+
)
|
|
16
23
|
end
|
|
17
24
|
end
|
|
18
25
|
|
|
19
26
|
def destroy
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
27
|
+
if @role_action.result.delete
|
|
28
|
+
@role_actions = RoleActionService.new(current_user, query).index(@role.id)
|
|
29
|
+
respond_with_lesli(
|
|
30
|
+
:turbo => [
|
|
31
|
+
stream_notification_warning("Role privileges removed successfully!"),
|
|
32
|
+
turbo_stream.replace('shield-role-actions-form', partial: 'lesli_shield/role/actions/form')
|
|
33
|
+
]
|
|
34
|
+
)
|
|
28
35
|
else
|
|
29
|
-
|
|
36
|
+
respond_with_lesli(
|
|
37
|
+
:turbo => stream_notification_danger(@role_action.errors_as_sentence)
|
|
38
|
+
)
|
|
30
39
|
end
|
|
31
40
|
end
|
|
32
41
|
|
|
33
42
|
private
|
|
34
43
|
|
|
35
|
-
|
|
44
|
+
def set_role
|
|
45
|
+
@role = current_user.account.roles.find(params[:role_id])
|
|
46
|
+
end
|
|
47
|
+
|
|
36
48
|
def set_role_action
|
|
37
|
-
@role_action =
|
|
49
|
+
@role_action = RoleActionService.new(current_user).find(params[:id])
|
|
38
50
|
end
|
|
39
51
|
|
|
40
52
|
def role_action_params
|
|
@@ -34,13 +34,25 @@ module LesliShield
|
|
|
34
34
|
class RolesController < ApplicationController
|
|
35
35
|
before_action :set_role, only: %i[ show update destroy ]
|
|
36
36
|
|
|
37
|
+
def deploy
|
|
38
|
+
pp params[:id]
|
|
39
|
+
pp params[:id]
|
|
40
|
+
pp params[:id]
|
|
41
|
+
pp params[:id]
|
|
42
|
+
|
|
43
|
+
RolePrivilegeService.new.synchronize(Lesli::Role.first)
|
|
44
|
+
|
|
45
|
+
respond_with_lesli(
|
|
46
|
+
:turbo => stream_notification_success("success")
|
|
47
|
+
)
|
|
48
|
+
end
|
|
49
|
+
|
|
37
50
|
def index
|
|
38
|
-
@roles =
|
|
51
|
+
@roles = respond_with_pagination(Lesli::RoleService.new(current_user, query).index)
|
|
39
52
|
end
|
|
40
53
|
|
|
41
54
|
def show
|
|
42
55
|
@role = @role.show
|
|
43
|
-
@role_actions = Lesli::Role::ActionService.new(current_user, query).index(@role.id)
|
|
44
56
|
end
|
|
45
57
|
|
|
46
58
|
# @return [HTML] HTML view for creating a new role
|
|
@@ -100,13 +112,9 @@ module LesliShield
|
|
|
100
112
|
|
|
101
113
|
# check if the update went OK
|
|
102
114
|
if @role.successful?
|
|
103
|
-
|
|
104
|
-
respond_to do |format|
|
|
105
|
-
format.turbo_stream
|
|
106
|
-
format.html { redirect_to @role }
|
|
107
|
-
end
|
|
115
|
+
respond_with_lesli(:turbo => stream_notification_success("Role updated successfully!"))
|
|
108
116
|
else
|
|
109
|
-
|
|
117
|
+
respond_with_lesli(:turbo => stream_notification_danger(@role.errors_as_sentence))
|
|
110
118
|
end
|
|
111
119
|
end
|
|
112
120
|
|
|
@@ -4,14 +4,11 @@ module LesliShield
|
|
|
4
4
|
|
|
5
5
|
# GET /sessions
|
|
6
6
|
def index
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
respond_with_pagination(UserSessionService.new(current_user, query).index())
|
|
13
|
-
}
|
|
14
|
-
end
|
|
7
|
+
@sessions = respond_with_pagination(UserSessionService.new(current_user, query).index())
|
|
8
|
+
respond_with_lesli(
|
|
9
|
+
:html => @sessions,
|
|
10
|
+
:json => @sessions
|
|
11
|
+
)
|
|
15
12
|
end
|
|
16
13
|
|
|
17
14
|
# GET /sessions/1
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
module LesliShield
|
|
2
|
+
class User::RolesController < ApplicationController
|
|
3
|
+
before_action :set_user_role, only: %i[ show edit update destroy ]
|
|
4
|
+
|
|
5
|
+
# GET /user/roles
|
|
6
|
+
def index
|
|
7
|
+
@user_roles = User::Role.all
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
# GET /user/roles/1
|
|
11
|
+
def show
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
# GET /user/roles/new
|
|
15
|
+
def new
|
|
16
|
+
@user_role = User::Role.new
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
# GET /user/roles/1/edit
|
|
20
|
+
def edit
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
# POST /user/roles
|
|
24
|
+
def create
|
|
25
|
+
# @user_role = User::Role.new(user_role_params)
|
|
26
|
+
|
|
27
|
+
# if @user_role.save
|
|
28
|
+
# redirect_to @user_role, notice: "Role was successfully created."
|
|
29
|
+
# else
|
|
30
|
+
# render :new, status: :unprocessable_content
|
|
31
|
+
# end
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
# PATCH/PUT /user/roles/1
|
|
35
|
+
def update
|
|
36
|
+
# if @user_role.update(user_role_params)
|
|
37
|
+
# redirect_to @user_role, notice: "Role was successfully updated.", status: :see_other
|
|
38
|
+
# else
|
|
39
|
+
# render :edit, status: :unprocessable_content
|
|
40
|
+
# end
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
# DELETE /user/roles/1
|
|
44
|
+
def destroy
|
|
45
|
+
@user_role.destroy!
|
|
46
|
+
redirect_to user_roles_path, notice: "Role was successfully destroyed.", status: :see_other
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
private
|
|
50
|
+
# Use callbacks to share common setup or constraints between actions.
|
|
51
|
+
def set_user_role
|
|
52
|
+
@user_role = User::Role.find(params.expect(:id))
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
# Only allow a list of trusted parameters through.
|
|
56
|
+
def user_role_params
|
|
57
|
+
params.require(:user_role).permit(
|
|
58
|
+
:role_id
|
|
59
|
+
)
|
|
60
|
+
end
|
|
61
|
+
end
|
|
62
|
+
end
|
|
@@ -1,20 +1,52 @@
|
|
|
1
|
+
=begin
|
|
2
|
+
|
|
3
|
+
Lesli
|
|
4
|
+
|
|
5
|
+
Copyright (c) 2026, 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 LesliTech
|
|
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
|
+
|
|
1
33
|
module LesliShield
|
|
2
34
|
class UsersController < ApplicationController
|
|
3
35
|
before_action :set_user, only: %i[ show edit update destroy ]
|
|
4
36
|
|
|
5
37
|
# GET /users
|
|
6
38
|
def index
|
|
7
|
-
@users =
|
|
39
|
+
@users = respond_with_pagination(Lesli::UserService.new(current_user, query).index(params))
|
|
8
40
|
end
|
|
9
41
|
|
|
10
42
|
# GET /users/1
|
|
11
43
|
def show
|
|
12
|
-
@
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
44
|
+
@user_roles = @user.result.roles
|
|
45
|
+
@activities = @user.result.logs
|
|
46
|
+
.order(id: :desc)
|
|
47
|
+
.select(:id, :operation, :description, Date2.new.db_column('created_at', as:'date'))
|
|
48
|
+
.limit(7)
|
|
49
|
+
.as_json
|
|
18
50
|
@sessions = @user.result.sessions
|
|
19
51
|
@user = @user.show
|
|
20
52
|
end
|
|
@@ -33,44 +65,49 @@ module LesliShield
|
|
|
33
65
|
@user = User.new(user_params)
|
|
34
66
|
|
|
35
67
|
if @user.save
|
|
36
|
-
|
|
68
|
+
respond_with_stream(
|
|
69
|
+
stream_notification_success('User was successfully created.')
|
|
70
|
+
)
|
|
37
71
|
else
|
|
38
|
-
|
|
72
|
+
respond_with_stream(
|
|
73
|
+
stream_notification_danger(@user.errors.full_messages.to_sentence)
|
|
74
|
+
)
|
|
39
75
|
end
|
|
40
76
|
end
|
|
41
77
|
|
|
42
78
|
# PATCH/PUT /users/1
|
|
43
79
|
def update
|
|
44
80
|
|
|
45
|
-
# check if the user trully exists
|
|
46
|
-
return respond_with_not_found unless @user.found?
|
|
47
|
-
|
|
48
81
|
# update the user information
|
|
49
82
|
@user.update(user_params)
|
|
50
83
|
|
|
51
84
|
# check saved
|
|
52
85
|
if @user.successful?
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
format.html { redirect_to @user }
|
|
57
|
-
end
|
|
86
|
+
respond_with_lesli(
|
|
87
|
+
:turbo => stream_notification_success("User updated successfully!")
|
|
88
|
+
)
|
|
58
89
|
else
|
|
59
|
-
|
|
90
|
+
respond_with_lesli(
|
|
91
|
+
:turbo => stream_notification_danger(@user.errors_as_sentence)
|
|
92
|
+
)
|
|
60
93
|
end
|
|
61
94
|
end
|
|
62
95
|
|
|
63
96
|
# DELETE /users/1
|
|
64
97
|
def destroy
|
|
65
98
|
@user.destroy!
|
|
66
|
-
redirect_to
|
|
99
|
+
redirect_to(users_path, notice: "User was successfully destroyed.", status: :see_other)
|
|
67
100
|
end
|
|
68
101
|
|
|
69
102
|
private
|
|
70
103
|
|
|
71
|
-
# Use callbacks to share common setup or constraints between actions.
|
|
72
104
|
def set_user
|
|
105
|
+
|
|
106
|
+
# Search for the user
|
|
73
107
|
@user = Lesli::UserService.new(current_user).find(params[:id])
|
|
108
|
+
|
|
109
|
+
# check if the user trully exists
|
|
110
|
+
return respond_with_not_found unless @user.found?
|
|
74
111
|
end
|
|
75
112
|
|
|
76
113
|
# Only allow a list of trusted parameters through.
|
|
@@ -1,4 +1,36 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
=begin
|
|
4
|
+
|
|
5
|
+
Lesli
|
|
6
|
+
|
|
7
|
+
Copyright (c) 2026, Lesli Technologies, S. A.
|
|
8
|
+
|
|
9
|
+
This program is free software: you can redistribute it and/or modify
|
|
10
|
+
it under the terms of the GNU General Public License as published by
|
|
11
|
+
the Free Software Foundation, either version 3 of the License, or
|
|
12
|
+
(at your option) any later version.
|
|
13
|
+
|
|
14
|
+
This program is distributed in the hope that it will be useful,
|
|
15
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
16
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
17
|
+
GNU General Public License for more details.
|
|
18
|
+
|
|
19
|
+
You should have received a copy of the GNU General Public License
|
|
20
|
+
along with this program. If not, see http://www.gnu.org/licenses/.
|
|
21
|
+
|
|
22
|
+
Lesli · Ruby on Rails SaaS Development Framework.
|
|
23
|
+
|
|
24
|
+
Made with ♥ by LesliTech
|
|
25
|
+
Building a better future, one line of code at a time.
|
|
26
|
+
|
|
27
|
+
@contact hello@lesli.tech
|
|
28
|
+
@website https://www.lesli.tech
|
|
29
|
+
@license GPLv3 http://www.gnu.org/licenses/gpl-3.0.en.html
|
|
30
|
+
|
|
31
|
+
// · ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~
|
|
32
|
+
// ·
|
|
33
|
+
=end
|
|
2
34
|
class Users::ConfirmationsController < Devise::ConfirmationsController
|
|
3
35
|
|
|
4
36
|
def show
|
|
@@ -23,22 +55,24 @@ class Users::ConfirmationsController < Devise::ConfirmationsController
|
|
|
23
55
|
end
|
|
24
56
|
|
|
25
57
|
# register a log with a validation atempt for the user
|
|
26
|
-
|
|
58
|
+
log = user.log(engine: LesliShield, source: self.class.name, action: action_name, operation: "user_confirmation", description: "Confirmation process started")
|
|
27
59
|
|
|
28
|
-
|
|
29
|
-
|
|
60
|
+
# create a new instance of the registration service
|
|
61
|
+
registration_service = LesliShield::UserRegistrationService.new(user)
|
|
30
62
|
|
|
31
63
|
# confirm the user
|
|
32
|
-
|
|
64
|
+
registration_service.confirm
|
|
65
|
+
|
|
66
|
+
# send a welcome email to user as is confirmed
|
|
67
|
+
LesliShield::DeviseMailer.with(user: resource).welcome.deliver_later
|
|
33
68
|
|
|
34
69
|
# let the user knows that the confirmation is done
|
|
35
70
|
flash[:success] = I18n.t("core.users/confirmations.messages_success_email_updated")
|
|
36
71
|
|
|
37
|
-
#
|
|
38
|
-
|
|
39
|
-
registration_operator.create_account if user.account.blank?
|
|
40
|
-
#Thread.new { registration_operator.create_account } if user.account.blank?
|
|
72
|
+
# setup the new account
|
|
73
|
+
registration_service.create_account if user.account.blank?
|
|
41
74
|
|
|
75
|
+
log.update(description: 'User confirmed successfully') if defined?(LesliAudit)
|
|
42
76
|
end
|
|
43
77
|
|
|
44
78
|
|
|
@@ -1,66 +1,81 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
=begin
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
def create
|
|
7
|
-
begin
|
|
5
|
+
Lesli
|
|
8
6
|
|
|
9
|
-
|
|
10
|
-
#Account::Activity.log("core", "/password/create", "password_creation_failed", "no_valid_email")
|
|
11
|
-
raise(I18n.t("core.shared.messages_warning_user_not_found"))
|
|
12
|
-
end
|
|
7
|
+
Copyright (c) 2026, Lesli Technologies, S. A.
|
|
13
8
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
9
|
+
This program is free software: you can redistribute it and/or modify
|
|
10
|
+
it under the terms of the GNU General Public License as published by
|
|
11
|
+
the Free Software Foundation, either version 3 of the License, or
|
|
12
|
+
(at your option) any later version.
|
|
18
13
|
|
|
19
|
-
|
|
14
|
+
This program is distributed in the hope that it will be useful,
|
|
15
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
16
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
17
|
+
GNU General Public License for more details.
|
|
20
18
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
# email: (params[:user][:email] || "")
|
|
24
|
-
# })
|
|
25
|
-
raise(I18n.t("core.shared.messages_warning_user_not_found"))
|
|
26
|
-
end
|
|
19
|
+
You should have received a copy of the GNU General Public License
|
|
20
|
+
along with this program. If not, see http://www.gnu.org/licenses/.
|
|
27
21
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
22
|
+
Lesli · Ruby on Rails SaaS Development Framework.
|
|
23
|
+
|
|
24
|
+
Made with ♥ by LesliTech
|
|
25
|
+
Building a better future, one line of code at a time.
|
|
26
|
+
|
|
27
|
+
@contact hello@lesli.tech
|
|
28
|
+
@website https://www.lesli.tech
|
|
29
|
+
@license GPLv3 http://www.gnu.org/licenses/gpl-3.0.en.html
|
|
30
|
+
|
|
31
|
+
// · ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~
|
|
32
|
+
// ·
|
|
33
|
+
=end
|
|
34
|
+
|
|
35
|
+
class Users::PasswordsController < Devise::PasswordsController
|
|
36
|
+
|
|
37
|
+
# Sends an email with a token, so the user can reset their password
|
|
38
|
+
def create
|
|
39
|
+
self.resource = resource_class.send_reset_password_instructions(resource_params)
|
|
40
|
+
|
|
41
|
+
user = self.resource
|
|
33
42
|
|
|
34
|
-
|
|
43
|
+
if successfully_sent?(resource)
|
|
35
44
|
|
|
36
|
-
user.
|
|
45
|
+
user.log(
|
|
46
|
+
:engine => LesliShield,
|
|
47
|
+
:source => self.class.name,
|
|
48
|
+
:action => action_name,
|
|
49
|
+
:operation => 'password_reset',
|
|
50
|
+
:description => 'Reset password instructions sent'
|
|
51
|
+
)
|
|
37
52
|
|
|
38
|
-
Lesli::DeviseMailer.reset_password_instructions(user, token).deliver_now
|
|
39
53
|
success(I18n.t("core.users/passwords.messages_success"))
|
|
40
54
|
redirect_to(new_user_password_path)
|
|
41
|
-
|
|
42
|
-
#
|
|
43
|
-
danger(
|
|
55
|
+
else
|
|
56
|
+
#respond_with(resource)
|
|
57
|
+
danger("Error sending reset password instructions")
|
|
44
58
|
redirect_to(new_user_password_path)
|
|
45
59
|
end
|
|
46
60
|
end
|
|
47
61
|
|
|
48
62
|
def update
|
|
49
|
-
super do |
|
|
63
|
+
super do |user|
|
|
50
64
|
|
|
51
|
-
logs =
|
|
65
|
+
logs = user.log(engine: LesliShield, source: self.class.name, action: action_name, operation: 'password_update', description:"Password update attempt")
|
|
52
66
|
|
|
53
67
|
# check if password update was ok
|
|
54
|
-
if
|
|
68
|
+
if user.errors.empty?
|
|
55
69
|
|
|
56
70
|
# reset password expiration due the user just updated his password
|
|
57
|
-
if
|
|
58
|
-
|
|
71
|
+
if user.has_expired_password?
|
|
72
|
+
user.update(password_expiration_at: nil)
|
|
59
73
|
end
|
|
60
74
|
|
|
61
|
-
logs
|
|
75
|
+
logs&.update(description: "Password update successful")
|
|
62
76
|
else
|
|
63
|
-
|
|
77
|
+
danger(user.errors.full_messages.to_sentence)
|
|
78
|
+
logs&.update(description: resource.errors.full_messages.to_sentence)
|
|
64
79
|
end
|
|
65
80
|
end
|
|
66
81
|
end
|
|
@@ -43,6 +43,7 @@ class Users::RegistrationsController < Devise::RegistrationsController
|
|
|
43
43
|
|
|
44
44
|
def create
|
|
45
45
|
begin
|
|
46
|
+
|
|
46
47
|
# Check if instance allow multi-account
|
|
47
48
|
if !Lesli.config.security.dig(:allow_registration)
|
|
48
49
|
raise(I18n.t("core.users/registrations.messages_error_registration_not_allowed"))
|
|
@@ -51,16 +52,9 @@ class Users::RegistrationsController < Devise::RegistrationsController
|
|
|
51
52
|
# build new user
|
|
52
53
|
user = build_resource(sign_up_params)
|
|
53
54
|
|
|
54
|
-
# run password complexity validations
|
|
55
|
-
#user_validator = UsersValidator.new(user).password_complexity(sign_up_params[:password])
|
|
56
|
-
|
|
57
|
-
# return if there are errors with the complexity validations
|
|
58
|
-
# unless user_validator.valid?
|
|
59
|
-
# return respond_with_error("password_complexity_error", password_complexity.failures)
|
|
60
|
-
# end
|
|
61
|
-
|
|
62
55
|
# persist new user
|
|
63
56
|
if user.save
|
|
57
|
+
user.log(engine: LesliShield, source: self.class.name, action: action_name, operation: 'user_creation', description: 'User creation successfully')
|
|
64
58
|
success("Account created, check your email")
|
|
65
59
|
else
|
|
66
60
|
raise(user.errors.full_messages.to_sentence)
|