lesli_shield 1.0.0 → 1.0.1

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.
@@ -1,13 +1,46 @@
1
1
  module LesliShield
2
2
  class Role::ActionsController < ApplicationController
3
- #before_action :set_dashboard_component, only: %i[ show edit update destroy ]
3
+ before_action :set_role_action, only: %i[update destroy ]
4
4
 
5
5
  def update
6
- success("Role privileges updated successfully!")
7
- respond_to do |format|
8
- format.turbo_stream
9
- format.html { redirect_to @role }
6
+ # check saved
7
+ 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
14
+ else
15
+ respond_with_error(@user.errors)
10
16
  end
11
17
  end
18
+
19
+ 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 "hola"
28
+ else
29
+ respond_with_error(@user.errors)
30
+ end
31
+ end
32
+
33
+ private
34
+
35
+ # Use callbacks to share common setup or constraints between actions.
36
+ def set_role_action
37
+ @role_action = Lesli::Role::ActionService.new(current_user).find(params[:id])
38
+ end
39
+
40
+ def role_action_params
41
+ params.require(:role_action).permit(
42
+ :role_id
43
+ )
44
+ end
12
45
  end
13
46
  end
@@ -0,0 +1,43 @@
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 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
+ =end
32
+
33
+ module LesliShield
34
+ class Account < ApplicationRecord
35
+ belongs_to :account, class_name: "Lesli::Account"
36
+
37
+ after_create :initialize_account
38
+
39
+ def initialize_account
40
+ #Dashboard.initialize_dashboard(self)
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,39 @@
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
+
33
+ module LesliShield
34
+ class Tokens < ApplicationLesliService
35
+ def self.friendly_token(length:40)
36
+ Devise.friendly_token(length)
37
+ end
38
+ end
39
+ end
@@ -65,9 +65,9 @@ columns = [{
65
65
  <% row.with_cell do %>
66
66
  <% if action %>
67
67
  <%= button_to role_action_path(action),
68
- method: :patch,
69
- params: { action: { active: !action.active } },
70
- class: "mini-toggle #{'active' if action.active}" do %>
68
+ method: :delete,
69
+ class: "mini-toggle #{action[:active] == 1 ? 'active' : ''}",
70
+ form: { "x-data" => "toggleForm", "x-on:submit.prevent" => "submit($el)" } do %>
71
71
  <span class="mini-toggle-slider"></span>
72
72
  <% end %>
73
73
  <% end %>
@@ -76,3 +76,29 @@ columns = [{
76
76
  <% end %>
77
77
  <% end %>
78
78
  <% end %>
79
+ <script>
80
+ document.addEventListener('alpine:init', () => {
81
+ Alpine.data('toggleForm', () => ({
82
+ submit(form) {
83
+ const method = form.querySelector('input[name="_method"]')?.value?.toUpperCase() || form.method.toUpperCase();
84
+ fetch(form.action, {
85
+ method: method,
86
+ headers: {
87
+ 'X-CSRF-Token': document.querySelector('meta[name="csrf-token"]').content,
88
+ 'Accept': 'text/vnd.turbo-stream.html' // or 'application/json'
89
+ },
90
+ body: new URLSearchParams(new FormData(form))
91
+ }).then(response => {
92
+ if (!response.ok) throw new Error("Request failed");
93
+ return response.text();
94
+ }).then(() => {
95
+ // Success! Toggle the class
96
+ form.querySelector('button')?.classList.toggle('active');
97
+ }).catch(err => {
98
+ console.error("Error:", err);
99
+ alert("Something went wrong");
100
+ });
101
+ }
102
+ }))
103
+ });
104
+ </script>
@@ -3,11 +3,11 @@
3
3
  <% end %>
4
4
 
5
5
  <%= render LesliView::Components::Tabs.new() do |tabs| %>
6
- <% tabs.with_tab(title:"information", icon:"info_outline") do %>
7
- <%= render "form-information" %>
8
- <% end %>
9
6
  <% tabs.with_tab(title:"privileges", icon:"security") do %>
10
7
  <%= render "form-privileges" %>
11
8
  <% end %>
9
+ <% tabs.with_tab(title:"information", icon:"info_outline") do %>
10
+ <%= render "form-information" %>
11
+ <% end %>
12
12
  <% end %>
13
13
  <% end %>
@@ -30,10 +30,6 @@ Building a better future, one line of code at a time.
30
30
  // ·
31
31
  =end
32
32
 
33
-
34
- # · Tools used to build the Lesli Framework
35
- require "devise"
36
-
37
33
  module LesliShield
38
34
  class Engine < ::Rails::Engine
39
35
  isolate_namespace LesliShield
@@ -1,4 +1,4 @@
1
1
  module LesliShield
2
- VERSION = "1.0.0"
3
- BUILD = "1751336313"
2
+ VERSION = "1.0.1"
3
+ BUILD = "1752635550"
4
4
  end
data/readme.md CHANGED
@@ -1,30 +1,42 @@
1
- <div align="center">
2
- <img width="90" alt="Lesli Shield logo" src="../app/assets/images/lesli_shield/shield-logo.svg" />
1
+ <div align="center" class="documentation-header">
2
+ <img width="100" alt="LesliShield logo" src="./app/assets/images/lesli_shield/shield-logo.svg" />
3
3
  <h3 align="center">Authentication & Authorization for the Lesli Framework.</h3>
4
4
  </div>
5
5
 
6
+
7
+ <br />
6
8
  <hr/>
7
- <p align="center">
8
- <a target="blank" href="https://rubygems.org/gems/lesli_shield">
9
- <img src="https://badge.fury.io/rb/lesli_shield.svg" alt="Gem Version" height="24">
10
- </a>
11
- </p>
9
+
10
+ <div align="center" class="documentation-statics">
11
+ <a target="blank" href="https://rubygems.org/gems/lesli">
12
+ <img height="22" alt="Gem Version" src="https://badge.fury.io/rb/lesli.svg"/>
13
+ </a>
14
+ <a class="mx-2" href="https://codecov.io/github/LesliTech/Lesli">
15
+ <img height="22" src="https://codecov.io/github/LesliTech/Lesli/graph/badge.svg?token=2O12NENK5Y"/>
16
+ </a>
17
+ <a href="https://codecov.io/github/LesliTech/LesliBabel">
18
+ <img height="22" src="https://sonarcloud.io/api/project_badges/measure?project=LesliTech_LesliBabel&metric=sqale_rating"/>
19
+ </a>
20
+ </div>
21
+
12
22
  <hr/>
23
+ <br />
24
+
13
25
 
14
26
  ### Quick start
15
27
 
16
28
  ```shell
17
- # Add LesliShield engine
29
+ # Add LesliShield engine gem
18
30
  bundle add lesli_shield
19
31
  ```
20
32
 
21
33
  ```shell
22
- # Setup database
34
+ # Setup & initialize the database
23
35
  rake lesli:db:setup
24
36
  ```
25
37
 
26
38
  ```ruby
27
- # Load LesliShield
39
+ # Load LesliShield engine
28
40
  Rails.application.routes.draw do
29
41
  mount LesliShield::Engine => "/shield"
30
42
  end
@@ -32,21 +44,24 @@ end
32
44
 
33
45
 
34
46
  ### Documentation
47
+
48
+
49
+
50
+ ### Lesli Documentation
35
51
  * [website](https://www.lesli.dev/)
36
- * [database](./docs/database.md)
37
52
  * [documentation](https://www.lesli.dev/engines/shield/)
38
53
 
39
54
 
40
55
  ### Get in touch with Lesli
41
56
 
42
- * [Website: https://www.lesli.tech](https://www.lesli.tech)
43
57
  * [Email: hello@lesli.tech](hello@lesli.tech)
58
+ * [Website: https://www.lesli.tech](https://www.lesli.tech)
44
59
  * [Twitter: @LesliTech](https://twitter.com/LesliTech)
45
60
 
46
61
 
47
62
  ### License
48
63
  -------
49
- Copyright (c) 2023, Lesli Technologies, S. A.
64
+ Copyright (c) 2025, Lesli Technologies, S. A.
50
65
 
51
66
  This program is free software: you can redistribute it and/or modify
52
67
  it under the terms of the GNU General Public License as published by
@@ -64,8 +79,7 @@ along with this program. If not, see http://www.gnu.org/licenses/.
64
79
  <hr />
65
80
  <br />
66
81
 
67
- <p align="center">
82
+ <div align="center" class="has-text-centered">
68
83
  <img width="200" alt="Lesli logo" src="https://cdn.lesli.tech/lesli/brand/app-logo.svg" />
69
- <h4 align="center">Ruby on Rails SaaS Development Framework.</h4>
70
- </p>
71
-
84
+ <h4 align="center" class="mt-0">Ruby on Rails SaaS Development Framework.</h4>
85
+ </div>
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.0
4
+ version: 1.0.1
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-01 00:00:00.000000000 Z
11
+ date: 2025-07-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: lesli
@@ -28,16 +28,16 @@ dependencies:
28
28
  name: devise
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - "~>"
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
- version: '4.9'
33
+ version: '0'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - "~>"
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
- version: '4.9'
40
+ version: '0'
41
41
  description: Authentication & Authorization management for the Lesli Framework.
42
42
  email:
43
43
  - hello@lesli.tech
@@ -83,11 +83,13 @@ files:
83
83
  - app/interfaces/lesli_shield/authorization_interface.rb
84
84
  - app/jobs/lesli_shield/application_job.rb
85
85
  - app/mailers/lesli_shield/application_mailer.rb
86
+ - app/models/lesli_shield/account.rb
86
87
  - app/models/lesli_shield/application_record.rb
87
88
  - app/models/lesli_shield/dashboard.rb
88
89
  - app/models/lesli_shield/dashboard/component.rb
89
90
  - app/models/lesli_shield/setting.rb
90
91
  - app/models/lesli_shield/user.rb
92
+ - app/services/lesli_shield/tokens.rb
91
93
  - app/views/devise/confirmations/new.html.erb
92
94
  - app/views/devise/confirmations/show.html.erb
93
95
  - app/views/devise/mailer/confirmation_instructions.html.erb