lesli_shield 1.1.5 → 1.1.7

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 (59) hide show
  1. checksums.yaml +4 -4
  2. data/Rakefile +3 -0
  3. data/app/assets/stylesheets/lesli_shield/application.css +140 -1
  4. data/app/assets/stylesheets/lesli_shield/confirmations.css +917 -18
  5. data/app/assets/stylesheets/lesli_shield/confirmations.tailwind.css +918 -0
  6. data/app/assets/stylesheets/lesli_shield/passwords.css +872 -18
  7. data/app/assets/stylesheets/lesli_shield/passwords.tailwind.css +873 -0
  8. data/app/assets/stylesheets/lesli_shield/registrations.css +904 -770
  9. data/app/assets/stylesheets/lesli_shield/registrations.tailwind.css +908 -0
  10. data/app/assets/stylesheets/lesli_shield/sessions.css +984 -32
  11. data/app/assets/stylesheets/lesli_shield/sessions.tailwind.css +983 -1
  12. data/app/controllers/lesli_shield/profile/passwords_controller.rb +119 -0
  13. data/app/controllers/lesli_shield/profiles_controller.rb +63 -0
  14. data/app/controllers/lesli_shield/sessions_controller.rb +1 -2
  15. data/app/controllers/lesli_shield/users_controller.rb +3 -7
  16. data/app/controllers/users/confirmations_controller.rb +162 -49
  17. data/app/controllers/users/passwords_controller.rb +211 -28
  18. data/app/controllers/users/registrations_controller.rb +108 -83
  19. data/app/controllers/users/sessions_controller.rb +122 -84
  20. data/app/interfaces/lesli_shield/authentication_interface.rb +3 -3
  21. data/app/interfaces/lesli_shield/authorization_interface.rb +2 -2
  22. data/app/mailers/lesli_shield/devise_mailer.rb +73 -17
  23. data/app/models/concerns/lesli_shield/user_authentication.rb +54 -0
  24. data/app/models/lesli_shield/account.rb +4 -1
  25. data/app/models/lesli_shield/invite.rb +1 -1
  26. data/app/models/lesli_shield/user/role.rb +1 -1
  27. data/app/models/lesli_shield/user.rb +5 -2
  28. data/app/services/lesli_shield/profile/password_service.rb +47 -0
  29. data/app/services/lesli_shield/profile_service.rb +24 -0
  30. data/app/services/lesli_shield/user_registration_service.rb +41 -74
  31. data/app/services/lesli_shield/user_session_service.rb +1 -1
  32. data/app/services/lesli_shield/user_validator_service.rb +35 -39
  33. data/app/views/devise/confirmations/new.html.erb +58 -12
  34. data/app/views/devise/confirmations/show.html.erb +27 -60
  35. data/app/views/devise/passwords/edit.html.erb +59 -25
  36. data/app/views/devise/passwords/new.html.erb +61 -26
  37. data/app/views/devise/registrations/new.html.erb +80 -53
  38. data/app/views/devise/sessions/new.html.erb +53 -36
  39. data/app/views/devise/shared/_application-devise-simple.erb +18 -19
  40. data/app/views/devise/shared/_demo.html.erb +8 -6
  41. data/app/views/devise/shared/_error_messages.html.erb +45 -10
  42. data/app/views/devise/shared/_links.html.erb +6 -13
  43. data/app/views/lesli_shield/invites/_form.html.erb +1 -1
  44. data/app/views/lesli_shield/invites/index.html.erb +3 -2
  45. data/app/views/lesli_shield/profiles/_password-form.html.erb +68 -0
  46. data/app/views/lesli_shield/profiles/show.html.erb +29 -0
  47. data/app/views/lesli_shield/users/_information-card.html.erb +35 -45
  48. data/app/views/lesli_shield/users/_information-form.html.erb +9 -1
  49. data/config/initializers/devise.rb +52 -328
  50. data/config/locales/translations.en.yml +65 -2
  51. data/config/locales/translations.es.yml +65 -2
  52. data/config/routes.rb +4 -0
  53. data/lib/lesli_shield/engine.rb +44 -4
  54. data/lib/lesli_shield/router.rb +52 -18
  55. data/lib/lesli_shield/version.rb +2 -2
  56. data/readme.md +6 -4
  57. metadata +30 -5
  58. data/app/assets/config/lesli_shield_manifest.js +0 -48
  59. data/app/assets/stylesheets/lesli_shield/application.tailwind.css +0 -0
@@ -30,15 +30,55 @@ Building a better future, one line of code at a time.
30
30
  // ·
31
31
  =end
32
32
 
33
+ require "devise"
34
+
33
35
  module LesliShield
34
36
  class Engine < ::Rails::Engine
35
37
  isolate_namespace LesliShield
36
38
 
37
- initializer :lesli_shield do |app|
38
-
39
- # register assets manifest
40
- config.assets.precompile += %w[lesli_shield_manifest.js]
39
+ # Rails 8 defers route loading in local environments. Load the main
40
+ # routes before the application starts accepting requests so Warden is
41
+ # initialized with the Devise mapping created by Shield's router.
42
+ config.after_initialize do |app|
43
+ app.routes_reloader.execute_unless_loaded
44
+ end
45
+
46
+ initializer "lesli_shield.authentication_routes" do
47
+ if Lesli::Router.respond_to?(:authentication_router=)
48
+ Lesli::Router.authentication_router = LesliShield::Router
49
+ end
50
+ end
51
+
52
+ config.to_prepare do
53
+ unless Lesli::User < LesliShield::UserAuthentication
54
+ Lesli::User.include(LesliShield::UserAuthentication)
55
+ end
56
+
57
+ unless Lesli::User < LesliShield::UserSecurity
58
+ Lesli::User.include(LesliShield::UserSecurity)
59
+ end
60
+
61
+ # Compatibility for core versions whose Devise base controller did
62
+ # not explicitly expose Lesli helpers to isolated engines.
63
+ devise_controller = Lesli::ApplicationDeviseController
64
+ core_helper_modules = [Lesli::SystemHelper, Lesli::HtmlHelper]
65
+
66
+ # The controller and layout live in Lesli, while Shield owns the
67
+ # specialized Devise forms. Put those forms before Devise's bundled
68
+ # defaults in the lookup order whenever Shield is installed.
69
+ shield_views = LesliShield::Engine.root.join("app", "views")
70
+ unless devise_controller.view_paths.first&.to_path == shield_views.to_s
71
+ devise_controller.prepend_view_path(shield_views)
72
+ end
73
+
74
+ core_helper_modules.each do |helper_module|
75
+ next if devise_controller._helpers < helper_module
41
76
 
77
+ devise_controller.helper(helper_module)
78
+ end
79
+ end
80
+
81
+ initializer :lesli_shield do |app|
42
82
  # register engine migrations path
43
83
  unless app.root.to_s.match root.to_s
44
84
  config.paths["db/migrate"].expanded.each do |expanded_path|
@@ -1,21 +1,55 @@
1
- module LesliShield
1
+ # frozen_string_literal: true
2
+
3
+ module LesliShield
2
4
  module Router
3
- def self.mount_login_at(router, path="")
4
- router.devise_for :users, class_name: "Lesli::User", module: :devise,
5
- :path => path,
6
- :path_names => {
7
- :sign_in => "login",
8
- :sign_out => "logout",
9
- :sign_up => "register",
10
- :password => "password",
11
- :confirmation => "confirmation"
12
- },
13
- :controllers => {
14
- :registrations => "users/registrations",
15
- :confirmations => "users/confirmations",
16
- :passwords => "users/passwords",
17
- :sessions => "users/sessions"
18
- }
5
+ def self.mount_login_at(router, path = "")
6
+ # Devise derives and memoizes the mapping strategies while
7
+ # devise_for builds the routes. Install Shield's Devise modules
8
+ # first so a cold application boot cannot produce an empty mapping.
9
+ unless Lesli::User < LesliShield::UserAuthentication
10
+ Lesli::User.include(LesliShield::UserAuthentication)
11
+ end
12
+
13
+ router.devise_for(
14
+ :users,
15
+ class_name: "Lesli::User",
16
+ module: :devise,
17
+ path: path,
18
+ path_names: {
19
+ sign_in: "login",
20
+ sign_out: "logout",
21
+ sign_up: "register",
22
+ password: "password",
23
+ confirmation: "confirmation"
24
+ },
25
+ controllers: {
26
+ registrations: "users/registrations",
27
+ confirmations: "users/confirmations",
28
+ passwords: "users/passwords",
29
+ sessions: "users/sessions"
30
+ }
31
+ )
32
+
33
+ configure_warden_user_mapping
19
34
  end
20
- end
35
+
36
+ def self.configure_warden_user_mapping
37
+ mapping = Devise.mappings.fetch(:user)
38
+
39
+ Devise.warden_config.scope_defaults(
40
+ mapping.name,
41
+ strategies: mapping.strategies
42
+ )
43
+
44
+ Devise.warden_config.serialize_into_session(mapping.name) do |record|
45
+ mapping.to.serialize_into_session(record)
46
+ end
47
+
48
+ Devise.warden_config.serialize_from_session(mapping.name) do |args|
49
+ mapping.to.serialize_from_session(*args)
50
+ end
51
+ end
52
+
53
+ private_class_method :configure_warden_user_mapping
54
+ end
21
55
  end
@@ -1,4 +1,4 @@
1
1
  module LesliShield
2
- VERSION = "1.1.5"
3
- BUILD = "1789353654"
2
+ VERSION = "1.1.7"
3
+ BUILD = "1792716699"
4
4
  end
data/readme.md CHANGED
@@ -8,8 +8,8 @@
8
8
  <br />
9
9
 
10
10
  <div align="center">
11
- <a target="_blank" href="https://github.com/LesliTech/LesliShield/actions/workflows/lesli-ci-tests.yaml">
12
- <img alt="LesliShield test status" src="https://img.shields.io/github/actions/workflow/status/LesliTech/LesliShield/lesli-ci-tests.yaml?branch=master&style=for-the-badge&logo=github&label=tests">
11
+ <a target="_blank" href="https://github.com/LesliTech/LesliShield/actions/workflows/lesli-ci-engine.yaml">
12
+ <img alt="LesliShield test status" src="https://img.shields.io/github/actions/workflow/status/LesliTech/LesliShield/lesli-ci-engine.yaml?branch=master&style=for-the-badge&logo=github&label=tests">
13
13
  </a>
14
14
  <a target="_blank" href="https://rubygems.org/gems/lesli_shield">
15
15
  <img alt="Gem Version" src="https://img.shields.io/gem/v/lesli_shield?style=for-the-badge&logo=ruby">
@@ -46,6 +46,7 @@ It centralizes account security, role-based access control, and user onboarding
46
46
  ## Features
47
47
 
48
48
  - Authentication and session management
49
+ - Self-service profile and password management
49
50
  - Role-based access control
50
51
  - Permission and privilege administration
51
52
  - Account-scoped security policies
@@ -73,7 +74,7 @@ Add the engine to the host Rails application and prepare its database:
73
74
 
74
75
  ```shell
75
76
  bundle add lesli_shield
76
- bin/rails db:prepare
77
+ bin/rails lesli:db:prepare
77
78
  ```
78
79
 
79
80
  ### Mount the engine
@@ -124,7 +125,7 @@ Install dependencies, prepare the host database, and start Rails:
124
125
 
125
126
  ```shell
126
127
  bundle install
127
- bin/rails db:prepare
128
+ bin/rails lesli:db:prepare
128
129
  bin/rails server
129
130
  ```
130
131
 
@@ -143,6 +144,7 @@ bin/rails test
143
144
 
144
145
  - [Lesli website](https://www.lesli.dev/)
145
146
  - [Documentation](https://www.lesli.dev/engines/shield)
147
+ - [User profile](https://www.lesli.dev/engines/shield/profile/overview)
146
148
  - [Release notes](https://github.com/LesliTech/LesliShield/releases)
147
149
  - [Issue tracker](https://github.com/LesliTech/LesliShield/issues)
148
150
  - [Source code](https://github.com/LesliTech/LesliShield)
metadata CHANGED
@@ -1,13 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lesli_shield
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.5
4
+ version: 1.1.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - The Lesli Development Team
8
+ autorequire:
8
9
  bindir: bin
9
10
  cert_chain: []
10
- date: 1980-01-02 00:00:00.000000000 Z
11
+ date: 2026-10-23 00:00:00.000000000 Z
11
12
  dependencies:
12
13
  - !ruby/object:Gem::Dependency
13
14
  name: lesli
@@ -23,6 +24,20 @@ dependencies:
23
24
  - - "~>"
24
25
  - !ruby/object:Gem::Version
25
26
  version: 5.1.0
27
+ - !ruby/object:Gem::Dependency
28
+ name: devise
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: 5.0.0
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: 5.0.0
26
41
  description: "Provides a complete authentication and authorization solution for The
27
42
  Lesli Framework, \nincluding user session management, secure login and logout, role-based
28
43
  access control, \nand permission handling.\n"
@@ -33,7 +48,6 @@ extensions: []
33
48
  extra_rdoc_files: []
34
49
  files:
35
50
  - Rakefile
36
- - app/assets/config/lesli_shield_manifest.js
37
51
  - app/assets/images/lesli_shield/login-background.jpg
38
52
  - app/assets/images/lesli_shield/register-background.jpg
39
53
  - app/assets/images/lesli_shield/shield-logo.svg
@@ -43,17 +57,21 @@ files:
43
57
  - app/assets/javascripts/lesli_shield/registrations.js
44
58
  - app/assets/javascripts/lesli_shield/sessions.js
45
59
  - app/assets/stylesheets/lesli_shield/application.css
46
- - app/assets/stylesheets/lesli_shield/application.tailwind.css
47
60
  - app/assets/stylesheets/lesli_shield/confirmations.css
61
+ - app/assets/stylesheets/lesli_shield/confirmations.tailwind.css
48
62
  - app/assets/stylesheets/lesli_shield/devise/oauth.css
49
63
  - app/assets/stylesheets/lesli_shield/passwords.css
64
+ - app/assets/stylesheets/lesli_shield/passwords.tailwind.css
50
65
  - app/assets/stylesheets/lesli_shield/registrations.css
66
+ - app/assets/stylesheets/lesli_shield/registrations.tailwind.css
51
67
  - app/assets/stylesheets/lesli_shield/sessions.css
52
68
  - app/assets/stylesheets/lesli_shield/sessions.tailwind.css
53
69
  - app/assets/stylesheets/lesli_shield/users.css
54
70
  - app/controllers/lesli_shield/application_controller.rb
55
71
  - app/controllers/lesli_shield/dashboards_controller.rb
56
72
  - app/controllers/lesli_shield/invites_controller.rb
73
+ - app/controllers/lesli_shield/profile/passwords_controller.rb
74
+ - app/controllers/lesli_shield/profiles_controller.rb
57
75
  - app/controllers/lesli_shield/role/actions_controller.rb
58
76
  - app/controllers/lesli_shield/roles_controller.rb
59
77
  - app/controllers/lesli_shield/sessions_controller.rb
@@ -79,6 +97,7 @@ files:
79
97
  - app/mailers/lesli_shield/application_mailer.rb
80
98
  - app/mailers/lesli_shield/devise_mailer.rb
81
99
  - app/mailers/lesli_shield/invitation.html.erb
100
+ - app/models/concerns/lesli_shield/user_authentication.rb
82
101
  - app/models/concerns/lesli_shield/user_security.rb
83
102
  - app/models/lesli_shield/account.rb
84
103
  - app/models/lesli_shield/application_record.rb
@@ -91,6 +110,8 @@ files:
91
110
  - app/models/lesli_shield/user/role.rb
92
111
  - app/models/lesli_shield/user/session.rb
93
112
  - app/services/lesli_shield/invite_service.rb
113
+ - app/services/lesli_shield/profile/password_service.rb
114
+ - app/services/lesli_shield/profile_service.rb
94
115
  - app/services/lesli_shield/role_action_service.rb
95
116
  - app/services/lesli_shield/role_privilege_service.rb
96
117
  - app/services/lesli_shield/tokens.rb
@@ -128,6 +149,8 @@ files:
128
149
  - app/views/lesli_shield/invites/new.html.erb
129
150
  - app/views/lesli_shield/invites/show.html.erb
130
151
  - app/views/lesli_shield/partials/_navigation.html.erb
152
+ - app/views/lesli_shield/profiles/_password-form.html.erb
153
+ - app/views/lesli_shield/profiles/show.html.erb
131
154
  - app/views/lesli_shield/role/actions/_form.html.erb
132
155
  - app/views/lesli_shield/role/actions/index.html.erb
133
156
  - app/views/lesli_shield/roles/_form.html.erb
@@ -190,6 +213,7 @@ metadata:
190
213
  source_code_uri: https://github.com/LesliTech/LesliShield
191
214
  bug_tracker_uri: https://github.com/LesliTech/LesliShield/issues
192
215
  documentation_uri: https://www.lesli.dev/engines/shield/
216
+ post_install_message:
193
217
  rdoc_options: []
194
218
  require_paths:
195
219
  - lib
@@ -204,7 +228,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
204
228
  - !ruby/object:Gem::Version
205
229
  version: '0'
206
230
  requirements: []
207
- rubygems_version: 3.7.1
231
+ rubygems_version: 3.5.16
232
+ signing_key:
208
233
  specification_version: 4
209
234
  summary: Users & security management for the Lesli Framework.
210
235
  test_files: []
@@ -1,48 +0,0 @@
1
- /*
2
- Lesli
3
-
4
- Copyright (c) 2023, Lesli Technologies, S. A.
5
-
6
- This program is free software: you can redistribute it and/or modify
7
- it under the terms of the GNU General Public License as published by
8
- the Free Software Foundation, either version 3 of the License, or
9
- (at your option) any later version.
10
-
11
- This program is distributed in the hope that it will be useful,
12
- but WITHOUT ANY WARRANTY; without even the implied warranty of
13
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
- GNU General Public License for more details.
15
-
16
- You should have received a copy of the GNU General Public License
17
- along with this program. If not, see http://www.gnu.org/licenses/.
18
-
19
- Lesli · Ruby on Rails SaaS Development Framework.
20
-
21
- Made with ♥ by https://www.lesli.tech
22
- Building a better future, one line of code at a time.
23
-
24
- @contact hello@lesli.tech
25
- @website https://www.lesli.dev
26
- @license GPLv3 http://www.gnu.org/licenses/gpl-3.0.en.html
27
-
28
- // · ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~
29
- // ·
30
- */
31
-
32
- //= link_tree ../images/lesli_shield .png
33
- //= link_tree ../images/lesli_shield .jpg
34
- //= link_tree ../images/lesli_shield .svg
35
-
36
- //= link lesli_shield/application.css
37
- //= link lesli_shield/application.js
38
- //= link lesli_shield/sessions.tailwind.css
39
-
40
-
41
- //= link lesli_shield/sessions.js
42
- //= link lesli_shield/sessions.css
43
- //= link lesli_shield/passwords.js
44
- //= link lesli_shield/passwords.css
45
- //= link lesli_shield/registrations.js
46
- //= link lesli_shield/registrations.css
47
- //= link lesli_shield/confirmations.js
48
- //= link lesli_shield/confirmations.css