role_authorization 0.1.1 → 0.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.
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: role_authorization
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.1.
|
5
|
+
version: 0.1.2
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- John 'asceth' Long
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2011-02-
|
13
|
+
date: 2011-02-24 00:00:00 -05:00
|
14
14
|
default_executable:
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
@@ -66,7 +66,6 @@ files:
|
|
66
66
|
- lib/role_authorization/rules/access.rb
|
67
67
|
- lib/role_authorization/rules/basic.rb
|
68
68
|
- lib/role_authorization/rules/custom.rb
|
69
|
-
- lib/role_authorization/rules/logged_in.rb
|
70
69
|
- lib/role_authorization/rules/object_role.rb
|
71
70
|
- lib/role_authorization/rules/resource.rb
|
72
71
|
- lib/role_authorization/rules/user.rb
|
@@ -1,38 +0,0 @@
|
|
1
|
-
module RoleAuthorization
|
2
|
-
# define our rule helper in Mapper
|
3
|
-
class Mapper
|
4
|
-
def logged_in(options={}, &block)
|
5
|
-
options.assert_valid_keys(:only)
|
6
|
-
rule(:logged_in, :logged_in, options, &block)
|
7
|
-
end
|
8
|
-
end
|
9
|
-
|
10
|
-
module Exts
|
11
|
-
module View
|
12
|
-
def logged_in(&block)
|
13
|
-
if block_given? && !current_user.anonymous?
|
14
|
-
capture_haml(&block)
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
module Rules
|
21
|
-
class LoggedIn < Basic
|
22
|
-
def initialize(controller, options, &block)
|
23
|
-
@controller_klass = controller
|
24
|
-
@options = options
|
25
|
-
self
|
26
|
-
end
|
27
|
-
|
28
|
-
def to_s
|
29
|
-
"allow when current_user is logged in (not anonymous)"
|
30
|
-
end
|
31
|
-
|
32
|
-
def authorized?(controller_instance, controller, action, id)
|
33
|
-
return true unless controller_instance.current_user.anonymous?
|
34
|
-
return false
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|