lotus_admin 1.4.0 → 1.4.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 82eb960c647ff89e930551906a0886cdac56255ea0fe989ab6861cb486f81ca1
4
- data.tar.gz: df0111ec129d5ad11c9e01fc40891a5199bead2a68322b186c445842e32d9010
3
+ metadata.gz: 52d4737f0f995337c89e2dfa7183364fc45e134bdd69ab8333485f9feff7eae4
4
+ data.tar.gz: 2474b390b2d5c7dbf0f1209dde38b3263a4368c86228b49af0b1efe6d5b2aaae
5
5
  SHA512:
6
- metadata.gz: 72efc100e64e636b9cda77a6f67610e336b2e9445d6081cba2a93006063e18ed060f0e1bc09ee0becd9da07c8820c9d6d49271f1e77d8d222f62e31c77c57b69
7
- data.tar.gz: b5539dd34e997fb8c3502a4dc5818a2effc7126ab0ca0b082deef56d5cd3aa2e4bd857fb97cd17c8834e153551631b6fda834e6a9c290684c07ebdaa6163d5f1
6
+ metadata.gz: a85c4256b0e83f67ed69f340d627e707d3ff5a5fb8fa7f58cf03b209636f1fbd4522c9294e83737130a82e7230a8ab06badec56a96bc91810f5d5fcd08d19162
7
+ data.tar.gz: 3a0a4f62f9c62775cf14b197fa69facc65c5038ae5bb7598aeaa3902637fa95112f6d7891af405bcc84e7cd3e121f18c11faf1ccb71227a1a1ec29513ed68ee6
@@ -25,7 +25,7 @@ module LotusAdmin
25
25
  def beginning_of_association_chain
26
26
  chain = super
27
27
 
28
- if self.class._policy_class_name.present?
28
+ if using_pundit?
29
29
  policy_scope(chain, policy_scope_class: "#{ self.class._policy_class_name }::Scope".constantize)
30
30
  else
31
31
  chain
@@ -33,8 +33,11 @@ module LotusAdmin
33
33
  end
34
34
 
35
35
  def user_not_authorized
36
- flash[:alert] = "You are not authorized to perform this action."
37
- redirect_to(request.referrer || root_path)
36
+ redirect_to root_path, alert: "You are not authorized to perform this action."
37
+ end
38
+
39
+ def using_pundit?
40
+ self.class._policy_class_name.present?
38
41
  end
39
42
  end
40
43
  end
@@ -17,11 +17,15 @@ class LotusAdmin::ResourceController < LotusAdmin::AuthenticatedController
17
17
 
18
18
  def new
19
19
  self.resource = build_resource
20
+
21
+ authorize(resource) if using_pundit?
20
22
  end
21
23
 
22
24
  def create
23
25
  self.resource = build_resource(permitted_params)
24
26
 
27
+ authorize(resource) if using_pundit?
28
+
25
29
  if resource.save
26
30
  redirect_to [lotus_admin, resource], notice: "Created new #{ resource_class.model_name.human } successfully"
27
31
  else
@@ -30,6 +34,8 @@ class LotusAdmin::ResourceController < LotusAdmin::AuthenticatedController
30
34
  end
31
35
 
32
36
  def update
37
+ authorize(resource) if using_pundit?
38
+
33
39
  if resource.update(permitted_params)
34
40
  redirect_to [lotus_admin, resource], notice: "Updated new #{ resource_class.model_name.human } successfully"
35
41
  else
@@ -38,6 +44,8 @@ class LotusAdmin::ResourceController < LotusAdmin::AuthenticatedController
38
44
  end
39
45
 
40
46
  def index(&block)
47
+ authorize(resource_class) if using_pundit?
48
+
41
49
  respond_to do |format|
42
50
  format.html
43
51
 
@@ -45,7 +53,13 @@ class LotusAdmin::ResourceController < LotusAdmin::AuthenticatedController
45
53
  end
46
54
  end
47
55
 
56
+ def show
57
+ authorize(resource) if using_pundit?
58
+ end
59
+
48
60
  def destroy
61
+ authorize(resource) if using_pundit?
62
+
49
63
  if resource.destroy
50
64
  flash[:notice] = "#{ resource_class.model_name.human } has been removed"
51
65
  else
@@ -1,3 +1,3 @@
1
1
  module LotusAdmin
2
- VERSION = '1.4.0'
2
+ VERSION = '1.4.1'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lotus_admin
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.0
4
+ version: 1.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matt Millsaps-Brewer