adeia 0.11.3 → 0.11.4

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
  SHA1:
3
- metadata.gz: 7d55bf4d1f23821b28a7e453f0aa030954df9bba
4
- data.tar.gz: a874f2f01d9092f65c625c8c832188298bc3dbc9
3
+ metadata.gz: 81d2d0a434685e7b16bff8d0803c04baa84da393
4
+ data.tar.gz: a5067a6f38c733b0dfa7462a23765f43358fa598
5
5
  SHA512:
6
- metadata.gz: 8894cbe01c843cc2ea722f6725f4c0db4b45c3681494b425c6dda9da5bb17eb445c307dbd552accd3a128368585574e0b0d937d589201d62edfee09da29f4005
7
- data.tar.gz: 84f112edfeaeb3c54aee55be8030c36afdd1faedc9e648c5d487e36c5f8eb9aead5c99cac8294dd572c126ffd20dc2b5be7d6e3d32c3e95546e48659cf89f9fe
6
+ metadata.gz: aff98a001374ef10190b2a0aea55691838137facab69d94b9408f59db39d48c6030640a85a6e70b26343844d915fdfdc527e1c85a57e4a6f5ff870c41d705c2f
7
+ data.tar.gz: 7e8c2cd42e38b26e2cf091bcda0ee0bc825fff4849ac5c185ccc17bc4173d82967bbe9ef9431f80736146c9016318e7b53d69bb9a9bc76f54815cb2f16e81691
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Adeia
2
2
 
3
- An authorization gem for Rails that allows you to have the complete control of your app.
3
+ An discretionary authorization gem for Rails that allows you to have the complete control of your app.
4
4
 
5
5
  ## Installation
6
6
 
@@ -29,8 +29,15 @@ mount Adeia::Engine => "/adeia"
29
29
  ### Tasks
30
30
 
31
31
  The first task to run is `rake adeia:permissions elements="first_element, second_element"`. It creates the given elements in the database and a superadmin group which has all the permissions.
32
- Then you can run `adeia:superuser user_id=your_id`, which add the given user in the superadmin group.
33
- If you need to add new groups, run `adeia:groups groups="first_group, second_group"`.
32
+ Then you can run `rake adeia:superuser user_id=your_id`, which add the given user in the superadmin group.
33
+ If you need to add new groups, run `rake adeia:groups groups="first_group, second_group"`.
34
+
35
+ For example:
36
+
37
+ ```
38
+ rake adeia:permissions elements="admin/galleries, admin/articles, admin/categories"
39
+ rake adeia:superuser user_id=59
40
+ ```
34
41
 
35
42
  ## Requirements
36
43
 
@@ -65,8 +65,8 @@ module Adeia
65
65
  # - default path to redirect to
66
66
  # * *Returns* :
67
67
  #
68
- def redirect_back_or(default, message = nil)
69
- redirect_to(cookies[:return_to] || default, message)
68
+ def redirect_back_or(default, **args)
69
+ redirect_to(cookies[:return_to] || default, **args)
70
70
  cookies.delete(:return_to)
71
71
  end
72
72
 
@@ -33,7 +33,7 @@ module Adeia
33
33
  @token = args.fetch(:token, @controller.request.GET[:token])
34
34
  @resource = args[:resource]
35
35
  @user = @controller.current_user
36
- @controller.current_user ||= User.new # if not signed in but authorized
36
+ @controller.current_user ||= GuestUser.new # if not signed in but authorized
37
37
  @controller.store_location
38
38
  end
39
39
 
data/lib/adeia/engine.rb CHANGED
@@ -19,21 +19,16 @@ module Adeia
19
19
  initializer 'Adeia.requirements' do |app|
20
20
  begin
21
21
  User
22
+ require 'adeia/guest_user'
22
23
  rescue NameError
23
24
  raise MissingUserModel
24
25
  end
25
26
  end
26
27
 
27
- initializer 'Adeia.user_addictions' do |app|
28
- User.send :include, Adeia::Helpers::UserHelper
29
- end
30
-
31
- initializer 'Adeia.controller_methods' do |app|
32
- ActionController::Base.send :include, Adeia::ControllerMethods
33
- end
34
-
35
- initializer 'Adeia.sessions_helper' do |app|
28
+ config.to_prepare do
36
29
  ActionController::Base.send :include, Adeia::Helpers::SessionsHelper
30
+ ActionController::Base.send :include, Adeia::ControllerMethods
31
+ User.send :include, Adeia::Helpers::UserHelper
37
32
  end
38
33
 
39
34
  end
@@ -0,0 +1,17 @@
1
+ module Adeia
2
+ class GuestUser < User
3
+
4
+ def nil?
5
+ true
6
+ end
7
+
8
+ def blank?
9
+ true
10
+ end
11
+
12
+ def present?
13
+ false
14
+ end
15
+
16
+ end
17
+ end
data/lib/adeia/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Adeia
2
- VERSION = "0.11.3"
2
+ VERSION = "0.11.4"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: adeia
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.11.3
4
+ version: 0.11.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - khcr
@@ -185,6 +185,7 @@ files:
185
185
  - lib/adeia/database.rb
186
186
  - lib/adeia/engine.rb
187
187
  - lib/adeia/exceptions.rb
188
+ - lib/adeia/guest_user.rb
188
189
  - lib/adeia/helpers/sessions_helper.rb
189
190
  - lib/adeia/helpers/user_helper.rb
190
191
  - lib/adeia/version.rb