tkh_authentication 0.0.11 → 0.0.12

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG.md CHANGED
@@ -2,6 +2,12 @@
2
2
 
3
3
 
4
4
 
5
+ ## 0.0.12
6
+
7
+ * Added an administrator? method
8
+ * Refactored the authenicate_as_admin method
9
+
10
+
5
11
  ## 0.0.11
6
12
 
7
13
  * Modified some German translation strings.
@@ -16,12 +16,16 @@ module TkhAuthenticationActionControllerExtension
16
16
  end
17
17
 
18
18
  def authenticate_with_admin
19
- unless current_user && current_user.admin?
19
+ unless administrator?
20
20
  session[:target_page] = request.url if session[:target_page].nil?
21
21
  redirect_to safe_root_url, alert: t('authentication.warning.restricted_access')
22
22
  end
23
23
  end
24
24
 
25
+ def administrator?
26
+ current_user && current_user.admin?
27
+ end
28
+
25
29
  private
26
30
 
27
31
  def safe_root_url
@@ -6,9 +6,14 @@ module TkhAuthenticationHelper
6
6
  end
7
7
 
8
8
  module InstanceMethods
9
- # duplicated it from action controller extension. there must be a better way
9
+ # duplicated from action controller extension. there must be a better way
10
10
  def current_user
11
11
  @current_user ||= User.find_by_auth_token!(cookies[:auth_token]) if cookies[:auth_token]
12
12
  end
13
+
14
+ # duplicated from action controller extension. there must be a better way
15
+ def administrator?
16
+ @administrator ||= current_user && current_user.admin?
17
+ end
13
18
  end
14
19
  end
@@ -1,3 +1,3 @@
1
1
  module TkhAuthentication
2
- VERSION = "0.0.11"
2
+ VERSION = "0.0.12"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tkh_authentication
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.11
4
+ version: 0.0.12
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-09-19 00:00:00.000000000 Z
12
+ date: 2013-01-08 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
@@ -172,7 +172,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
172
172
  version: '0'
173
173
  segments:
174
174
  - 0
175
- hash: 221164348588848249
175
+ hash: 3442867698929455310
176
176
  required_rubygems_version: !ruby/object:Gem::Requirement
177
177
  none: false
178
178
  requirements:
@@ -181,7 +181,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
181
181
  version: '0'
182
182
  segments:
183
183
  - 0
184
- hash: 221164348588848249
184
+ hash: 3442867698929455310
185
185
  requirements: []
186
186
  rubyforge_project:
187
187
  rubygems_version: 1.8.23