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.
Files changed (115) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/stylesheets/lesli_shield/confirmations.css +18763 -0
  3. data/app/assets/stylesheets/lesli_shield/devise/oauth.css +32 -0
  4. data/app/assets/stylesheets/lesli_shield/passwords.css +18717 -1
  5. data/app/assets/stylesheets/lesli_shield/registrations.css +18804 -1
  6. data/app/assets/stylesheets/lesli_shield/sessions.css +18804 -1
  7. data/app/assets/stylesheets/lesli_shield/users.css +30 -0
  8. data/app/controllers/lesli_shield/dashboards_controller.rb +1 -8
  9. data/app/controllers/lesli_shield/invites_controller.rb +80 -0
  10. data/app/controllers/lesli_shield/role/actions_controller.rb +32 -20
  11. data/app/controllers/lesli_shield/roles_controller.rb +16 -8
  12. data/app/controllers/lesli_shield/sessions_controller.rb +5 -8
  13. data/app/controllers/lesli_shield/user/roles_controller.rb +62 -0
  14. data/app/controllers/lesli_shield/users_controller.rb +57 -20
  15. data/app/controllers/users/confirmations_controller.rb +42 -8
  16. data/app/controllers/users/passwords_controller.rb +52 -37
  17. data/app/controllers/users/registrations_controller.rb +2 -8
  18. data/app/controllers/users/sessions_controller.rb +57 -50
  19. data/app/helpers/lesli_shield/invites_helper.rb +4 -0
  20. data/app/helpers/lesli_shield/user/roles_helper.rb +4 -0
  21. data/app/interfaces/lesli_shield/authorization_interface.rb +8 -2
  22. data/app/mailers/lesli_shield/devise_mailer.rb +98 -0
  23. data/app/mailers/lesli_shield/invitation.html.erb +23 -0
  24. data/app/models/concerns/lesli_shield/user_security.rb +222 -0
  25. data/app/models/lesli_shield/account.rb +1 -1
  26. data/app/models/lesli_shield/dashboard.rb +1 -4
  27. data/app/models/lesli_shield/invite.rb +24 -0
  28. data/{lib/vue/confirmations.js → app/models/lesli_shield/role/action.rb} +17 -10
  29. data/{db/migrate/v1/0801003010_create_lesli_shield_dashboards.rb → app/models/lesli_shield/role/privilege.rb} +5 -4
  30. data/app/models/lesli_shield/user/role.rb +8 -0
  31. data/app/models/lesli_shield/user/session.rb +80 -0
  32. data/app/services/lesli_shield/invite_service.rb +43 -0
  33. data/app/services/lesli_shield/role_action_service.rb +118 -0
  34. data/app/services/lesli_shield/role_privilege_service.rb +112 -0
  35. data/app/{operators/lesli_shield/user_registration_operator.rb → services/lesli_shield/user_registration_service.rb} +26 -29
  36. data/app/services/lesli_shield/user_session_service.rb +78 -0
  37. data/app/services/lesli_shield/user_validator_service.rb +221 -0
  38. data/app/views/devise/confirmations/show.html.erb +4 -6
  39. data/app/views/devise/passwords/edit.html.erb +1 -2
  40. data/app/views/devise/passwords/new.html.erb +1 -1
  41. data/app/views/devise/registrations/new.html.erb +5 -4
  42. data/app/views/devise/sessions/new.html.erb +3 -2
  43. data/app/views/devise/shared/_application-devise-simple.erb +59 -0
  44. data/app/views/devise/shared/_application-devise.html.erb +76 -0
  45. data/app/views/lesli_shield/dashboards/_component-calendar.html.erb +1 -0
  46. data/app/views/lesli_shield/dashboards/_component-chart-bar.html.erb +6 -0
  47. data/app/views/lesli_shield/dashboards/_component-chart-line.html.erb +8 -0
  48. data/app/views/lesli_shield/dashboards/_component-count.html.erb +1 -0
  49. data/app/views/lesli_shield/dashboards/_component-date.html.erb +1 -0
  50. data/app/views/lesli_shield/dashboards/_component-weather.html.erb +1 -0
  51. data/app/views/lesli_shield/invites/_form.html.erb +10 -0
  52. data/app/views/lesli_shield/invites/_invite.html.erb +2 -0
  53. data/app/views/lesli_shield/invites/edit.html.erb +12 -0
  54. data/app/views/lesli_shield/invites/index.html.erb +66 -0
  55. data/{db/migrate/v1/0801001710_create_lesli_shield_settings.rb → app/views/lesli_shield/invites/new.html.erb} +9 -10
  56. data/{lib/vue/apps/dashboards/components/engine-version.vue → app/views/lesli_shield/invites/show.html.erb} +26 -43
  57. data/app/views/lesli_shield/partials/_navigation.html.erb +2 -4
  58. data/app/views/lesli_shield/{roles/_form-privileges.html.erb → role/actions/_form.html.erb} +5 -30
  59. data/app/views/lesli_shield/role/actions/index.html.erb +14 -0
  60. data/app/views/lesli_shield/roles/index.html.erb +2 -6
  61. data/app/views/lesli_shield/roles/new.html.erb +0 -11
  62. data/app/views/lesli_shield/roles/show.html.erb +5 -8
  63. data/app/views/lesli_shield/user/roles/_form.html.erb +17 -0
  64. data/app/views/lesli_shield/user/roles/_role.html.erb +2 -0
  65. data/app/views/lesli_shield/user/roles/edit.html.erb +12 -0
  66. data/app/views/lesli_shield/user/roles/index.html.erb +16 -0
  67. data/app/views/lesli_shield/user/roles/new.html.erb +11 -0
  68. data/app/views/lesli_shield/user/roles/show.html.erb +10 -0
  69. data/app/views/lesli_shield/users/{_viewer-activities.html.erb → _activities-viewer.html.erb} +2 -4
  70. data/app/views/lesli_shield/users/_information-card.html.erb +3 -3
  71. data/app/views/lesli_shield/users/_management-privileges.html.erb +74 -0
  72. data/app/views/lesli_shield/users/_management-security.html.erb +5 -0
  73. data/app/views/lesli_shield/users/index.html.erb +3 -7
  74. data/app/views/lesli_shield/users/new.html.erb +5 -11
  75. data/app/views/lesli_shield/users/show.html.erb +7 -5
  76. data/config/initializers/devise.rb +305 -304
  77. data/config/locales/translations.en.yml +4 -1
  78. data/config/locales/translations.es.yml +4 -1
  79. data/config/locales/translations.it.yml +4 -1
  80. data/config/routes.rb +7 -8
  81. data/db/migrate/v1/0801100210_create_lesli_shield_role_actions.rb +48 -0
  82. data/db/migrate/v1/0801100410_create_lesli_shield_role_privileges.rb +45 -0
  83. data/db/migrate/v1/0801110110_create_lesli_shield_user_roles.rb +43 -0
  84. data/db/migrate/v1/0801111210_create_lesli_shield_user_sessions.rb +56 -0
  85. data/db/migrate/v1/0801120110_create_lesli_shield_invites.rb +49 -0
  86. data/lib/lesli_shield/engine.rb +3 -3
  87. data/lib/lesli_shield/router.rb +21 -0
  88. data/lib/lesli_shield/version.rb +2 -2
  89. data/lib/lesli_shield.rb +1 -1
  90. data/lib/scss/_devise.scss +10 -0
  91. data/lib/scss/confirmations.scss +24 -24
  92. data/lib/tasks/lesli_shield_tasks.rake +1 -1
  93. data/readme.md +59 -20
  94. metadata +69 -44
  95. data/app/controllers/lesli_shield/dashboard/components_controller.rb +0 -60
  96. data/app/models/lesli_shield/dashboard/component.rb +0 -18
  97. data/app/views/lesli_shield/dashboards/edit.html.erb +0 -1
  98. data/app/views/lesli_shield/dashboards/index.html.erb +0 -9
  99. data/app/views/lesli_shield/dashboards/new.html.erb +0 -1
  100. data/app/views/lesli_shield/dashboards/show.html.erb +0 -1
  101. data/app/views/lesli_shield/roles/_session.html.erb +0 -2
  102. data/app/views/lesli_shield/roles/edit.html.erb +0 -12
  103. data/app/views/lesli_shield/roles/update.turbo_stream.erb +0 -3
  104. data/app/views/lesli_shield/users/update.turbo_stream.erb +0 -3
  105. data/lib/lesli_shield/routing.rb +0 -23
  106. data/lib/vue/application.js +0 -83
  107. data/lib/vue/apps/sessions/index.vue +0 -50
  108. data/lib/vue/passwords.js +0 -137
  109. data/lib/vue/registrations.js +0 -144
  110. data/lib/vue/sessions.js +0 -148
  111. data/lib/vue/stores/sessions.js +0 -43
  112. data/lib/vue/stores/translations.json +0 -162
  113. /data/app/views/lesli_shield/roles/{_form-information.html.erb → _form.html.erb} +0 -0
  114. /data/db/migrate/v1/{0801120310_create_lesli_shield_user_shortcuts.rb → 0801111010_create_lesli_shield_user_shortcuts.rb} +0 -0
  115. /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
+ */
@@ -1,11 +1,4 @@
1
1
  module LesliShield
2
- class DashboardsController < ApplicationController
3
- before_action :set_session, only: %i[ ]
4
-
5
- def index
6
- end
7
-
8
- def show
9
- end
2
+ class DashboardsController < Lesli::Shared::DashboardsController
10
3
  end
11
4
  end
@@ -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 :set_role_action, only: %i[update destroy ]
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
- success("Role privileges added successfully!")
9
- respond_to do |format|
10
- format.turbo_stream
11
- render turbo_stream: turbo_stream.replace("application-lesli-notifications", partial: "lesli/partials/application-lesli-notifications")
12
- #format.html { redirect_to role_path(@role_action.role_id) }
13
- end
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
- respond_with_error(@user.errors)
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
- # check saved
21
- if @role_action.result.destroy
22
- # success("Role privileges removed successfully!")
23
- # respond_to do |format|
24
- # format.turbo_stream
25
- # #format.html { redirect_to role_path(@role_action.role_id) }
26
- # end
27
- return true
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
- respond_with_error(@user.errors)
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
- # Use callbacks to share common setup or constraints between actions.
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 = Lesli::Role::ActionService.new(current_user).find(params[:id])
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 = respond_as_pagination(Lesli::RoleService.new(current_user, query).index)
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
- success("Role updated successfully!")
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
- respond_with_error(@role.errors)
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
- respond_to do |format|
8
- format.html {
9
- @sessions = respond_as_pagination(Lesli::User::SessionService.new(current_user, query).index())
10
- }
11
- format.json {
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 = respond_as_pagination(Lesli::UserService.new(current_user, query).index(params))
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
- @activities = @user.result.activities.order(id: :desc).map { |a| {
13
- id: a[:id],
14
- title: a[:title].titleize,
15
- description: a[:description],
16
- date: Date2.new(a[:created_at]).date_words
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
- redirect_to @user, notice: "User was successfully created."
68
+ respond_with_stream(
69
+ stream_notification_success('User was successfully created.')
70
+ )
37
71
  else
38
- render :new, status: :unprocessable_entity
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
- success("User updated successfully!")
54
- respond_to do |format|
55
- format.turbo_stream
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
- respond_with_error(@user.errors)
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 users_path, notice: "User was successfully destroyed.", status: :see_other
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
- activity = user.activities.create({ title: "user_confirmation", description: "Confirmation process started" })
58
+ log = user.log(engine: LesliShield, source: self.class.name, action: action_name, operation: "user_confirmation", description: "Confirmation process started")
27
59
 
28
-
29
- registration_operator = LesliShield::UserRegistrationOperator.new(user)
60
+ # create a new instance of the registration service
61
+ registration_service = LesliShield::UserRegistrationService.new(user)
30
62
 
31
63
  # confirm the user
32
- registration_operator.confirm
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
- # if new account, launch account onboarding in another thread,
38
- # so the user can continue with the registration process
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
- class Users::PasswordsController < Devise::PasswordsController
3
+ =begin
4
4
 
5
- # Sends an email with a token, so the user can reset their password
6
- def create
7
- begin
5
+ Lesli
8
6
 
9
- if params[:user].blank?
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
- if params[:user][:email].blank?
15
- #Account::Activity.log("core", "/password/create", "password_creation_failed", "no_valid_email")
16
- raise(I18n.t("core.shared.messages_warning_user_not_found"))
17
- end
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
- user = Lesli::User.find_by(:email => params[:user][:email])
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
- if user.blank?
22
- # Account::Activity.log("core", "/password/create", "password_creation_failed", "no_valid_email", {
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
- unless user.active
29
- user.activities.create({title: "password_creation_failed", description: "user_not_active"})
30
- # Account::Activity.log("core", "/password/create", "password_creation_failed", "user_not_active")
31
- raise(I18n.t("core.users/passwords.messages_danger_inactive_user"))
32
- end
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
- token = user.generate_password_reset_token
43
+ if successfully_sent?(resource)
35
44
 
36
- user.activities.create({ title: "password_create", description: "Password reset instructions sent" })
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
- rescue => exception
42
- #Honeybadger.notify(exception)
43
- danger(exception.message)
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 |resource|
63
+ super do |user|
50
64
 
51
- logs = resource.activities.new({ title: "password_reset", description:"atempt" })
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 resource.errors.empty?
68
+ if user.errors.empty?
55
69
 
56
70
  # reset password expiration due the user just updated his password
57
- if resource.has_expired_password?
58
- resource.update(password_expiration_at: nil)
71
+ if user.has_expired_password?
72
+ user.update(password_expiration_at: nil)
59
73
  end
60
74
 
61
- logs.update({ description: "successful" })
75
+ logs&.update(description: "Password update successful")
62
76
  else
63
- logs.update({ description: resource.errors.full_messages.to_sentence })
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)