lesli_shield 1.0.1 → 1.0.2

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.
@@ -24,7 +24,7 @@ module LesliShield
24
24
  # format.turbo_stream
25
25
  # #format.html { redirect_to role_path(@role_action.role_id) }
26
26
  # end
27
- return "hola"
27
+ return true
28
28
  else
29
29
  respond_with_error(@user.errors)
30
30
  end
@@ -40,7 +40,7 @@ module LesliShield
40
40
 
41
41
  def show
42
42
  @role = @role.show
43
- @role_actions = Lesli::Role::ActionService.new(current_user, query).index(nil)
43
+ @role_actions = Lesli::Role::ActionService.new(current_user, query).index(@role.id)
44
44
  end
45
45
 
46
46
  # @return [HTML] HTML view for creating a new role
@@ -26,7 +26,7 @@ class Users::ConfirmationsController < Devise::ConfirmationsController
26
26
  activity = user.activities.create({ title: "user_confirmation", description: "Confirmation process started" })
27
27
 
28
28
 
29
- registration_operator = Lesli::UserRegistrationOperator.new(user)
29
+ registration_operator = LesliShield::UserRegistrationOperator.new(user)
30
30
 
31
31
  # confirm the user
32
32
  registration_operator.confirm
@@ -4,7 +4,7 @@
4
4
 
5
5
  Lesli
6
6
 
7
- Copyright (c) 2023, Lesli Technologies, S. A.
7
+ Copyright (c) 2025, Lesli Technologies, S. A.
8
8
 
9
9
  This program is free software: you can redistribute it and/or modify
10
10
  it under the terms of the GNU General Public License as published by
@@ -21,7 +21,7 @@ along with this program. If not, see http://www.gnu.org/licenses/.
21
21
 
22
22
  Lesli · Ruby on Rails SaaS Development Framework.
23
23
 
24
- Made with ♥ by https://www.lesli.tech
24
+ Made with ♥ by LesliTech
25
25
  Building a better future, one line of code at a time.
26
26
 
27
27
  @contact hello@lesli.tech
@@ -28,12 +28,12 @@ module LesliShield
28
28
  # privilege for object not found
29
29
  if granted.blank?
30
30
  current_user.activities.create({ title: "privilege_not_found", description: request.path })
31
- return respond_with_unauthorized({ controller: params[:controller], privilege: params[:action] })
31
+ return respond_with_unauthorized({ controller: params[:controller], action: params[:action] })
32
32
  end
33
33
 
34
34
  unless granted
35
35
  current_user.activities.create({ title: "privilege_not_granted", description: request.path })
36
- return respond_with_unauthorized({ controller: params[:controller], privilege: params[:action] })
36
+ return respond_with_unauthorized({ controller: params[:controller], action: params[:action] })
37
37
  end
38
38
  end
39
39
  end
@@ -33,11 +33,12 @@ Building a better future, one line of code at a time.
33
33
  module LesliShield
34
34
  class Account < ApplicationRecord
35
35
  belongs_to :account, class_name: "Lesli::Account"
36
+ has_many :dashboards
36
37
 
37
38
  after_create :initialize_account
38
39
 
39
40
  def initialize_account
40
- #Dashboard.initialize_dashboard(self)
41
+ Dashboard.initialize_account(self)
41
42
  end
42
43
  end
43
44
  end
@@ -1,31 +1,40 @@
1
+ =begin
2
+
3
+ Lesli
4
+
5
+ Copyright (c) 2025, 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 Dashboard < Lesli::Shared::Dashboard
3
35
  self.table_name = "lesli_shield_dashboards"
4
36
  belongs_to :account
5
37
 
6
- has_many :components, inverse_of: :dashboard, autosave: true, dependent: :destroy
7
- accepts_nested_attributes_for :components, allow_destroy: true
8
-
9
- def self.initialize_account(account)
10
- self.create!(
11
- account: account,
12
- name: "Audit Default Dashboard",
13
- default: true,
14
- main: false,
15
- components_attributes: [{
16
- name: "Total users",
17
- component_id: "audit-users",
18
- layout: 3,
19
- query_configuration: {},
20
- custom_configuration: {}
21
- }, {
22
- name: "Roles",
23
- component_id: "audit-roles",
24
- layout: 3,
25
- query_configuration: {},
26
- custom_configuration: {}
27
- }]
28
- )
29
- end
38
+ COMPONENTS = %i[]
30
39
  end
31
40
  end
@@ -0,0 +1,123 @@
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 LesliShield
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
+ Lesli::DeviseMailer.with(user: resource).welcome.deliver_later
57
+
58
+ # initialize user dependencies
59
+ current_user.after_confirmation
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 = Lesli::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 = Lesli::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.roles.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
+ default_role_id = nil
107
+
108
+ if default_role_id.present?
109
+ resource.roles.create({ role: account.roles.find_by(:id => default_role_id)})
110
+ else
111
+ resource.roles.create({ role: account.roles.find_by(name: "limited") })
112
+ end
113
+ end
114
+
115
+ # update user :)
116
+ resource.save
117
+
118
+ # initialize user dependencies
119
+ resource.after_account_assignation
120
+
121
+ end
122
+ end
123
+ end
@@ -31,7 +31,7 @@ Building a better future, one line of code at a time.
31
31
  =end
32
32
 
33
33
  module LesliShield
34
- class Tokens < ApplicationLesliService
34
+ class Tokens < Lesli::ApplicationLesliService
35
35
  def self.friendly_token(length:40)
36
36
  Devise.friendly_token(length)
37
37
  end
@@ -17,7 +17,7 @@
17
17
  label: "Enter your email address you use in Lesli. We'll send instructions for setting a new password to your email.")
18
18
  %>
19
19
 
20
- <%= form.field_control_button("Send me reset password instructions", icon:"email") %>
20
+ <%= form.field_control_button("Send me reset password instructions", icon:"mail") %>
21
21
 
22
22
  <% if Lesli.config.security.dig(:allow_registration) %>
23
23
  <p class="account has-text-centered">
@@ -31,6 +31,8 @@ Building a better future, one line of code at a time.
31
31
  %>
32
32
 
33
33
  <%
34
+
35
+ # Check if demo mode is enable on initializer file
34
36
  if Lesli.config.demo
35
37
  resource.email = Lesli.config.company[:email]
36
38
  resource.password = Lesli.config.security[:password]
@@ -65,7 +65,7 @@ columns = [{
65
65
  <% row.with_cell do %>
66
66
  <% if action %>
67
67
  <%= button_to role_action_path(action),
68
- method: :delete,
68
+ method: (action[:active] == 1 ? :delete : :patch),
69
69
  class: "mini-toggle #{action[:active] == 1 ? 'active' : ''}",
70
70
  form: { "x-data" => "toggleForm", "x-on:submit.prevent" => "submit($el)" } do %>
71
71
  <span class="mini-toggle-slider"></span>
@@ -87,7 +87,7 @@ columns = [{
87
87
  'X-CSRF-Token': document.querySelector('meta[name="csrf-token"]').content,
88
88
  'Accept': 'text/vnd.turbo-stream.html' // or 'application/json'
89
89
  },
90
- body: new URLSearchParams(new FormData(form))
90
+ //body: new URLSearchParams(new FormData(form))
91
91
  }).then(response => {
92
92
  if (!response.ok) throw new Error("Request failed");
93
93
  return response.text();
@@ -16,7 +16,7 @@
16
16
  <a class="level-item"
17
17
  href="'mailto:'+storeUser.user.email">
18
18
  <span class="icon is-small mr-2">
19
- <span class="material-icons">
19
+ <span class="material-symbols">
20
20
  email
21
21
  </span>
22
22
  </span>
@@ -25,7 +25,7 @@
25
25
  <a class="level-item mx-2"
26
26
  href="'tel:'+storeUser.user.telephone">
27
27
  <span class="icon is-small mr-2">
28
- <span class="material-icons">
28
+ <span class="material-symbols">
29
29
  phone
30
30
  </span>
31
31
  </span>
@@ -35,7 +35,7 @@
35
35
  <!-- Show the max role -->
36
36
  <p class="level-item" v-if="storeUser.role_names">
37
37
  <span class="icon is-small mr-2">
38
- <span class="material-icons">
38
+ <span class="material-symbols">
39
39
  security
40
40
  </span>
41
41
  </span>
@@ -4,7 +4,7 @@
4
4
 
5
5
  <%= render LesliView::Components::Tabs.new() do |tabs| %>
6
6
 
7
- <% tabs.with_tab(title:"information", icon:"info_outline") do %>
7
+ <% tabs.with_tab(title:"information", icon:"info") do %>
8
8
  <%= render "information-form" %>
9
9
  <% end %>
10
10
  <% tabs.with_tab(title:"Privileges", icon:"security") do %>
@@ -1,4 +1,4 @@
1
1
  module LesliShield
2
- VERSION = "1.0.1"
3
- BUILD = "1752635550"
2
+ VERSION = "1.0.2"
3
+ BUILD = "1754919086"
4
4
  end
@@ -33,7 +33,7 @@ Building a better future, one line of code at a time.
33
33
 
34
34
  // ·
35
35
  @use "lesli-css" as lesli;
36
- @use "LesliAssets/lib/lesli_assets_css/templates/public";
36
+ @use "LesliAssets/lib/lesli_assets_styles/templates/public";
37
37
 
38
38
 
39
39
  // ·
@@ -34,7 +34,7 @@ Building a better future, one line of code at a time.
34
34
 
35
35
  // ·
36
36
  @use "lesli-css" as lesli;
37
- @use "LesliAssets/lib/lesli_assets_css/templates/public";
37
+ @use "LesliAssets/lib/lesli_assets_styles/templates/public";
38
38
 
39
39
 
40
40
  // ·
@@ -45,23 +45,6 @@ Building a better future, one line of code at a time.
45
45
  }
46
46
 
47
47
 
48
- // · reusable background styles
49
- @mixin lesli-login-background() {
50
- background: linear-gradient(0deg,
51
- rgba(49, 106, 255, 0.4),
52
- rgba(49, 106, 255, 0.4)),
53
- url("lesli/brand/login-background.jpg");
54
- background-position: center;
55
- background-size: cover;
56
- }
57
-
58
-
59
- // column with image background right side
60
- .column.background {
61
- @include lesli-login-background;
62
- }
63
-
64
-
65
48
  // login form container
66
49
  .column.login-form {
67
50
  max-width: 550px;
@@ -144,7 +127,6 @@ Building a better future, one line of code at a time.
144
127
  .column.login-form {
145
128
  width: 100%;
146
129
  max-width: 100%;
147
- @include lesli-login-background;
148
130
 
149
131
  .hero {
150
132
  padding: 2rem 0;
@@ -31,5 +31,37 @@ Building a better future, one line of code at a time.
31
31
  */
32
32
 
33
33
 
34
+
35
+ // ·
36
+ @use "lesli-css" as lesli;
37
+
38
+
34
39
  // ·
35
40
  @use "devise";
41
+
42
+
43
+ // ·
44
+ @mixin lesli-register-background() {
45
+ background: linear-gradient(0deg,
46
+ rgba(49, 106, 255, 0.4),
47
+ rgba(49, 106, 255, 0.4)),
48
+ url("/lesli/brand/register-background.jpg");
49
+ background-position: center;
50
+ background-size: cover;
51
+ }
52
+
53
+
54
+ // ·
55
+ .column.background {
56
+ @include lesli-register-background;
57
+ }
58
+
59
+
60
+ // ·
61
+ @include lesli.lesli-breakpoint-until-tablet() {
62
+
63
+ // login column must be full width on mobile
64
+ .column.login-form {
65
+ @include lesli-register-background;
66
+ }
67
+ }
@@ -31,5 +31,36 @@ Building a better future, one line of code at a time.
31
31
  */
32
32
 
33
33
 
34
+ // ·
35
+ @use "lesli-css" as lesli;
36
+
37
+
34
38
  // ·
35
39
  @use "devise";
40
+
41
+
42
+ // ·
43
+ @mixin lesli-login-background() {
44
+ background: linear-gradient(0deg,
45
+ rgba(49, 106, 255, 0.4),
46
+ rgba(49, 106, 255, 0.4)),
47
+ url("/lesli/brand/login-background.jpg");
48
+ background-position: center;
49
+ background-size: cover;
50
+ }
51
+
52
+
53
+ // ·
54
+ .column.background {
55
+ @include lesli-login-background;
56
+ }
57
+
58
+
59
+ // ·
60
+ @include lesli.lesli-breakpoint-until-tablet() {
61
+
62
+ // login column must be full width on mobile
63
+ .column.login-form {
64
+ @include lesli-login-background;
65
+ }
66
+ }
@@ -34,16 +34,15 @@ namespace :lesli_shield do
34
34
 
35
35
  desc "Syncing privileges for all the available roles"
36
36
  task :privileges => :environment do |task, args|
37
- role_sync_privileges()
37
+ lesli_shield_privileges()
38
38
  end
39
39
 
40
40
  # Drop, build, migrate & seed database (development only)
41
- def role_sync_privileges
41
+ def lesli_shield_privileges
42
42
 
43
43
  Lesli::Role.all.each do |role|
44
+ L2.info("LesliShield: Syncing privileges for #{role.name} role.")
44
45
  Lesli::RoleOperator.new(role).synchronize
45
46
  end
46
-
47
- L2.msg("LesliShield: Syncing privileges for all the available roles")
48
47
  end
49
48
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lesli_shield
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - The Lesli Development Team
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2025-07-16 00:00:00.000000000 Z
11
+ date: 2025-08-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: lesli
@@ -89,6 +89,7 @@ files:
89
89
  - app/models/lesli_shield/dashboard/component.rb
90
90
  - app/models/lesli_shield/setting.rb
91
91
  - app/models/lesli_shield/user.rb
92
+ - app/operators/lesli_shield/user_registration_operator.rb
92
93
  - app/services/lesli_shield/tokens.rb
93
94
  - app/views/devise/confirmations/new.html.erb
94
95
  - app/views/devise/confirmations/show.html.erb