challah 0.4.1 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.md +5 -0
- data/db/migrate/20120127150434_create_roles.rb +1 -0
- data/lib/challah/authable/user.rb +26 -4
- data/lib/challah/version.rb +1 -1
- data/test/user_test.rb +1 -1
- metadata +10 -10
data/CHANGELOG.md
CHANGED
@@ -15,7 +15,7 @@ module Challah
|
|
15
15
|
|
16
16
|
before_save :before_save_password
|
17
17
|
|
18
|
-
belongs_to :role
|
18
|
+
belongs_to :role, :touch => true
|
19
19
|
has_many :permission_users, :dependent => :destroy
|
20
20
|
has_many :permissions, :through => :permission_users, :order => 'permissions.name'
|
21
21
|
|
@@ -131,8 +131,28 @@ module Challah
|
|
131
131
|
def permission_keys
|
132
132
|
return @permission_keys if @permission_keys
|
133
133
|
|
134
|
-
role_keys =
|
135
|
-
|
134
|
+
role_keys = if role(true)
|
135
|
+
role_key = "#{role.cache_key}/permissions"
|
136
|
+
|
137
|
+
keys = Rails.cache.fetch(role_key) do
|
138
|
+
role.permission_keys.clone
|
139
|
+
end
|
140
|
+
|
141
|
+
Rails.cache.write(role_key, keys)
|
142
|
+
keys
|
143
|
+
else
|
144
|
+
[]
|
145
|
+
end
|
146
|
+
|
147
|
+
user_key = "#{self.cache_key}/permissions"
|
148
|
+
|
149
|
+
user_keys = Rails.cache.fetch(user_key) do
|
150
|
+
user_permission_keys.clone
|
151
|
+
end
|
152
|
+
|
153
|
+
user_keys = [] unless user_keys
|
154
|
+
|
155
|
+
Rails.cache.write(user_key, keys) unless new_record?
|
136
156
|
|
137
157
|
@permission_keys = (role_keys + user_keys).uniq
|
138
158
|
end
|
@@ -145,6 +165,8 @@ module Challah
|
|
145
165
|
|
146
166
|
# Set the permission keys that this role can access
|
147
167
|
def permission_keys=(value)
|
168
|
+
Rails.cache.delete("#{self.cache_key}/permissions")
|
169
|
+
|
148
170
|
@permission_keys = value
|
149
171
|
@permission_keys
|
150
172
|
end
|
@@ -181,7 +203,7 @@ module Challah
|
|
181
203
|
|
182
204
|
# Returns the permission keys used by this specific user, does not include any role-based permissions.
|
183
205
|
def user_permission_keys
|
184
|
-
self.permissions(true).collect(&:key)
|
206
|
+
new_record? ? [] : self.permissions(true).collect(&:key)
|
185
207
|
end
|
186
208
|
|
187
209
|
# Is this user valid and ready for a user session?
|
data/lib/challah/version.rb
CHANGED
data/test/user_test.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: challah
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-02-
|
12
|
+
date: 2012-02-20 00:00:00.000000000Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: highline
|
16
|
-
requirement: &
|
16
|
+
requirement: &70359908531280 !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: *70359908531280
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: rails
|
27
|
-
requirement: &
|
27
|
+
requirement: &70359908624460 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: '3.1'
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *70359908624460
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: rake
|
38
|
-
requirement: &
|
38
|
+
requirement: &70359908623960 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ! '>='
|
@@ -43,10 +43,10 @@ dependencies:
|
|
43
43
|
version: 0.9.2
|
44
44
|
type: :runtime
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *70359908623960
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: bcrypt-ruby
|
49
|
-
requirement: &
|
49
|
+
requirement: &70359908623500 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ! '>='
|
@@ -54,7 +54,7 @@ dependencies:
|
|
54
54
|
version: '0'
|
55
55
|
type: :runtime
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *70359908623500
|
58
58
|
description: A simple ruby gem for authentication, users, roles and permissions.
|
59
59
|
email:
|
60
60
|
- john@johntornow.com
|