the_role 1.6.4 → 1.6.5
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +16 -11
- data/lib/the_role/modules/base.rb +7 -0
- data/lib/the_role/modules/role_model.rb +1 -0
- data/lib/the_role/version.rb +1 -1
- metadata +13 -13
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# gem 'the_role' (alpha v0.2)
|
1
|
+
# gem 'the_role' (alpha v0.2)
|
2
2
|
|
3
3
|
| Bye bye CanCan, I got The Role! | Description |
|
4
4
|
|:------------- |:-------------|
|
@@ -6,7 +6,7 @@
|
|
6
6
|
|
7
7
|
### GUI
|
8
8
|
|
9
|
-
| TheRole management web interface |
|
9
|
+
| TheRole management web interface => localhost:3000/admin/roles |
|
10
10
|
|:-------------:|
|
11
11
|
|![TheRole](https://github.com/the-teacher/the_role/raw/master/pic.png)|
|
12
12
|
|
@@ -132,35 +132,33 @@ rake db:roles:test
|
|
132
132
|
|
133
133
|
#### Change your ApplicationController
|
134
134
|
|
135
|
-
|
135
|
+
Define aliases method for correctly work TheRole's controllers
|
136
136
|
|
137
137
|
``` ruby
|
138
138
|
class ApplicationController < ActionController::Base
|
139
|
-
include TheRole::Requires
|
140
|
-
|
141
139
|
protect_from_forgery
|
142
140
|
|
143
141
|
def access_denied
|
144
142
|
render :text => 'access_denied: requires an role' and return
|
145
143
|
end
|
146
144
|
|
147
|
-
alias_method :login_required, :
|
145
|
+
alias_method :login_required, :YOUR_AUTH_SYSTEM_LOGIN_REQUIRE_METHOD
|
148
146
|
alias_method :role_access_denied, :access_denied
|
149
147
|
end
|
150
148
|
```
|
151
149
|
|
152
|
-
Define aliases method for correctly work TheRole's controllers
|
153
|
-
|
154
|
-
**authenticate_user!** or any other method from your auth system
|
155
|
-
|
156
150
|
**access_denied** or any other method for processing access denied situation
|
157
151
|
|
152
|
+
#### YOUR_AUTH_SYSTEM_LOGIN_REQUIRE_METHOD!
|
153
|
+
|
154
|
+
* **authenticate_user!** - method for Devise 2
|
155
|
+
* **require_login** - method for Sorcery
|
156
|
+
* **some_method** - from your Auth system
|
158
157
|
|
159
158
|
#### Using with any controller
|
160
159
|
|
161
160
|
``` ruby
|
162
161
|
class PagesController < ApplicationController
|
163
|
-
# Devise2 and TheRole before_filters
|
164
162
|
before_filter :login_required, :except => [:index, :show]
|
165
163
|
before_filter :role_required, :except => [:index, :show]
|
166
164
|
|
@@ -326,6 +324,12 @@ current_user.owner?(@article) => true | false
|
|
326
324
|
|
327
325
|
# JSON string
|
328
326
|
@role.to_s => String
|
327
|
+
|
328
|
+
# check method
|
329
|
+
@role.has_section?(:pages) => true | false
|
330
|
+
|
331
|
+
# check method
|
332
|
+
@role.has_rule?(:pages, :index) => true | false
|
329
333
|
```
|
330
334
|
|
331
335
|
#### UPDATE
|
@@ -366,6 +370,7 @@ new_role_hash = {
|
|
366
370
|
|
367
371
|
### Changelog
|
368
372
|
|
373
|
+
* 1.6.5 - has_section?, fixes, tests (alpha 0.3)
|
369
374
|
* 1.6.4 - En locale (alpha 0.2)
|
370
375
|
* 1.6.3 - notifications
|
371
376
|
* 1.6.0 - stabile release (alpha 0.1)
|
@@ -1,5 +1,12 @@
|
|
1
1
|
module TheRole
|
2
2
|
module Base
|
3
|
+
def has_section? section_name
|
4
|
+
hash = role_hash
|
5
|
+
section_name = param_prepare section_name
|
6
|
+
return true if hash[section_name]
|
7
|
+
false
|
8
|
+
end
|
9
|
+
|
3
10
|
def has_role? section_name, rule_name
|
4
11
|
hash = role_hash
|
5
12
|
section_name = param_prepare(section_name)
|
data/lib/the_role/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: the_role
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.6.
|
4
|
+
version: 1.6.5
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -13,7 +13,7 @@ date: 2012-07-24 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: haml
|
16
|
-
requirement: &
|
16
|
+
requirement: &16274880 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *16274880
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: sass
|
27
|
-
requirement: &
|
27
|
+
requirement: &16274440 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: '0'
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *16274440
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: sass-rails
|
38
|
-
requirement: &
|
38
|
+
requirement: &16274000 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ! '>='
|
@@ -43,10 +43,10 @@ dependencies:
|
|
43
43
|
version: '0'
|
44
44
|
type: :runtime
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *16274000
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: coffee-rails
|
49
|
-
requirement: &
|
49
|
+
requirement: &16273540 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ! '>='
|
@@ -54,10 +54,10 @@ dependencies:
|
|
54
54
|
version: '0'
|
55
55
|
type: :runtime
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *16273540
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
59
|
name: therubyracer
|
60
|
-
requirement: &
|
60
|
+
requirement: &16273060 !ruby/object:Gem::Requirement
|
61
61
|
none: false
|
62
62
|
requirements:
|
63
63
|
- - ! '>='
|
@@ -65,10 +65,10 @@ dependencies:
|
|
65
65
|
version: '0'
|
66
66
|
type: :runtime
|
67
67
|
prerelease: false
|
68
|
-
version_requirements: *
|
68
|
+
version_requirements: *16273060
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: less-rails
|
71
|
-
requirement: &
|
71
|
+
requirement: &16272540 !ruby/object:Gem::Requirement
|
72
72
|
none: false
|
73
73
|
requirements:
|
74
74
|
- - ! '>='
|
@@ -76,7 +76,7 @@ dependencies:
|
|
76
76
|
version: '0'
|
77
77
|
type: :runtime
|
78
78
|
prerelease: false
|
79
|
-
version_requirements: *
|
79
|
+
version_requirements: *16272540
|
80
80
|
description: Authorization lib for Rails 3 with Web Interface, aka CanCan killer
|
81
81
|
email:
|
82
82
|
- zykin-ilya@ya.ru
|