lesli_shield 1.1.0 → 1.1.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.
@@ -32,16 +32,10 @@ Building a better future, one line of code at a time.
32
32
 
33
33
  module LesliShield
34
34
  class RolesController < ApplicationController
35
- before_action :set_role, only: %i[ show update destroy ]
35
+ before_action :set_role, only: %i[ show update destroy deploy ]
36
36
 
37
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
-
38
+ RolePrivilegeService.new.synchronize(@role.result)
45
39
  respond_with_lesli(
46
40
  :turbo => stream_notification_success("success")
47
41
  )
@@ -1,64 +1,38 @@
1
1
  module LesliShield
2
- class SessionsController < ApplicationController
3
- before_action :set_session, only: %i[ show edit update destroy ]
4
-
5
- # GET /sessions
6
- def index
7
- @sessions = respond_with_pagination(UserSessionService.new(current_user, query).index())
8
- respond_with_lesli(
9
- :html => @sessions,
10
- :json => @sessions
11
- )
12
- end
13
-
14
- # GET /sessions/1
15
- def show
16
- end
17
-
18
- # GET /sessions/new
19
- def new
20
- @session = Session.new
21
- end
22
-
23
- # GET /sessions/1/edit
24
- def edit
25
- end
26
-
27
- # POST /sessions
28
- def create
29
- @session = Session.new(session_params)
30
-
31
- if @session.save
32
- redirect_to @session, notice: "Session was successfully created."
33
- else
34
- render :new, status: :unprocessable_entity
35
- end
36
- end
37
-
38
- # PATCH/PUT /sessions/1
39
- def update
40
- if @session.update(session_params)
41
- redirect_to @session, notice: "Session was successfully updated.", status: :see_other
42
- else
43
- render :edit, status: :unprocessable_entity
44
- end
2
+ class SessionsController < ApplicationController
3
+ before_action :set_session, only: %i[ show edit update destroy ]
4
+
5
+ # GET /sessions
6
+ def index
7
+ @sessions = respond_with_pagination(UserSessionService.new(current_user, query).index())
8
+ respond_with_lesli(
9
+ :html => @sessions,
10
+ :json => @sessions
11
+ )
12
+ end
13
+
14
+ # GET /sessions/1
15
+ def show
16
+ end
17
+
18
+ # PATCH/PUT /sessions/1
19
+ def update
20
+ end
21
+
22
+ # DELETE /sessions/1
23
+ def destroy
24
+ end
25
+
26
+ private
27
+
28
+ # Use callbacks to share common setup or constraints between actions.
29
+ def set_session
30
+ @session = Session.find(params.expect(:id))
31
+ end
32
+
33
+ # Only allow a list of trusted parameters through.
34
+ def session_params
35
+ params.fetch(:session, {})
36
+ end
45
37
  end
46
-
47
- # DELETE /sessions/1
48
- def destroy
49
- @session.destroy!
50
- redirect_to sessions_path, notice: "Session was successfully destroyed.", status: :see_other
51
- end
52
-
53
- private
54
- # Use callbacks to share common setup or constraints between actions.
55
- def set_session
56
- @session = Session.find(params.expect(:id))
57
- end
58
-
59
- # Only allow a list of trusted parameters through.
60
- def session_params
61
- params.fetch(:session, {})
62
- end
63
- end
64
38
  end
@@ -57,7 +57,7 @@ module LesliShield
57
57
  active: true
58
58
  ).exists?
59
59
  rescue => exception
60
- L2.danger(exception.to_s)
60
+ Termline.danger(exception.to_s)
61
61
  return false
62
62
  end
63
63
  end
@@ -21,20 +21,21 @@ module LesliShield
21
21
 
22
22
  Role::Action.with_deleted.joins(action: :parent)
23
23
  .where(:role_id => role_id)
24
+ .order('parents_lesli_resources.route')
24
25
  .select(
25
26
  :id,
26
27
  :role_id,
27
28
  :deleted_at,
28
29
  "parents_lesli_resources.id as controller_id",
29
30
  "parents_lesli_resources.label as controller_name",
31
+ "parents_lesli_resources.route as controller_route",
30
32
  "lesli_resources.action as action_name",
31
33
  "lesli_resources.id as action_id",
32
34
  "case when lesli_shield_role_actions.deleted_at is null then TRUE else FALSE end active"
33
35
  ).each do |action|
34
36
 
35
- unless role_actions.has_key?(action[:controller_name])
36
- role_actions[action[:controller_name]] = {
37
- list:nil,
37
+ unless role_actions.has_key?(action[:controller_route])
38
+ role_actions[action[:controller_route]] = {
38
39
  index: nil,
39
40
  show:nil,
40
41
  create:nil,
@@ -43,28 +44,24 @@ module LesliShield
43
44
  }
44
45
  end
45
46
 
46
- if action[:action_name] == "list"
47
- role_actions[action[:controller_name]][:list] = clean(action)
48
- end
49
-
50
47
  if action[:action_name] == "index"
51
- role_actions[action[:controller_name]][:index] = clean(action)
48
+ role_actions[action[:controller_route]][:index] = clean(action)
52
49
  end
53
50
 
54
51
  if action[:action_name] == "show"
55
- role_actions[action[:controller_name]][:show] = clean(action)
52
+ role_actions[action[:controller_route]][:show] = clean(action)
56
53
  end
57
54
 
58
55
  if action[:action_name] == "create"
59
- role_actions[action[:controller_name]][:create] = clean(action)
56
+ role_actions[action[:controller_route]][:create] = clean(action)
60
57
  end
61
58
 
62
59
  if action[:action_name] == "update"
63
- role_actions[action[:controller_name]][:update] = clean(action)
60
+ role_actions[action[:controller_route]][:update] = clean(action)
64
61
  end
65
62
 
66
63
  if action[:action_name] == "destroy"
67
- role_actions[action[:controller_name]][:destroy] = clean(action)
64
+ role_actions[action[:controller_route]][:destroy] = clean(action)
68
65
  end
69
66
  end
70
67
 
@@ -62,7 +62,7 @@ module LesliShield
62
62
  lesli_shield_role_actions.role_id as role_id,
63
63
  resource_controllers.route as controller,
64
64
  resource_actions.action as action,
65
- lesli_shield_role_actions.deleted_at IS NULL as active
65
+ case when lesli_shield_role_actions.deleted_at is null then TRUE else FALSE end active
66
66
  )).with_deleted
67
67
 
68
68
  # get privileges only for the given role, this is needed to sync only modified roles
@@ -2,8 +2,6 @@
2
2
  <%
3
3
  columns = [{
4
4
  label: "Controller"
5
- }, {
6
- label: "List"
7
5
  }, {
8
6
  label: "Index"
9
7
  }, {
@@ -14,8 +12,6 @@ columns = [{
14
12
  label: "Update"
15
13
  }, {
16
14
  label: "Destroy"
17
- }, {
18
- label: ""
19
15
  }]
20
16
  %>
21
17
 
@@ -1,4 +1,4 @@
1
1
  module LesliShield
2
- VERSION = "1.1.0"
3
- BUILD = "1774678451"
2
+ VERSION = "1.1.2"
3
+ BUILD = "1777694371"
4
4
  end
@@ -39,10 +39,9 @@ namespace :lesli_shield do
39
39
 
40
40
  # Drop, build, migrate & seed database (development only)
41
41
  def lesli_shield_privileges
42
-
43
42
  Lesli::Role.all.each do |role|
44
- L2.info("LesliShield: Syncing privileges for #{role.name} role.")
45
43
  LesliShield::RolePrivilegeService.new(nil).synchronize(role)
44
+ Termline.success("LesliShield: Syncing privileges for #{role.name} role.")
46
45
  end
47
46
  end
48
47
  end
data/readme.md CHANGED
@@ -1,6 +1,6 @@
1
1
  <div align="center">
2
2
  <img width="100" alt="LesliShield logo" src="./app/assets/images/lesli_shield/shield-logo.svg" />
3
- <h3 align="center">Administration area for the Lesli Framework.</h3>
3
+ <h3 align="center">Users & Security Management for the Lesli Framework.</h3>
4
4
  </div>
5
5
 
6
6
  <br />
@@ -33,15 +33,16 @@
33
33
 
34
34
  ### Installation
35
35
 
36
- ```shell
36
+ ```ruby
37
+
37
38
  # Add LesliShield engine gem
38
39
  bundle add lesli_shield
39
40
 
41
+
40
42
  # Setup & initialize the database
41
43
  rake lesli:db:setup
42
- ```
43
44
 
44
- ```ruby
45
+
45
46
  # Load LesliShield engine
46
47
  Rails.application.routes.draw do
47
48
  mount LesliShield::Engine => "/shield"
@@ -49,12 +50,12 @@ end
49
50
  ```
50
51
 
51
52
  <br />
52
- <hr/>
53
+ <hr />
53
54
  <br />
54
55
 
55
56
  ### Development
56
57
 
57
- ```shell
58
+ ```ruby
58
59
  # clone the lesli repo inside your engine folder: RailsApp/engines
59
60
  git clone https://github.com/LesliTech/LesliShield.git
60
61
 
@@ -70,7 +71,7 @@ rake lesli:db:setup
70
71
  ```
71
72
 
72
73
  <br />
73
- <hr/>
74
+ <hr />
74
75
  <br />
75
76
 
76
77
  ### Demo
@@ -86,9 +87,9 @@ rake lesli:db:setup
86
87
 
87
88
  ### Connect with Lesli
88
89
 
89
- * [X: @LesliTech](https://x.com/LesliTech)
90
- * [Email: hello@lesli.tech](hello@lesli.tech)
91
- * [Website: https://www.lesli.tech](https://www.lesli.tech)
90
+ * [@LesliTech](https://x.com/LesliTech)
91
+ * [hello@lesli.tech](hello@lesli.tech)
92
+ * [https://www.lesli.tech](https://www.lesli.tech)
92
93
 
93
94
 
94
95
  ### License
@@ -108,7 +109,6 @@ GNU General Public License for more details.
108
109
  You should have received a copy of the GNU General Public License
109
110
  along with this program. If not, see http://www.gnu.org/licenses/.
110
111
 
111
- <br />
112
112
  <hr />
113
113
  <br />
114
114
  <br />
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lesli_shield
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - The Lesli Development Team