warden-ocra 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
data/lib/warden-ocra.rb CHANGED
@@ -9,7 +9,7 @@ require 'warden-ocra/configuration'
9
9
  module Warden
10
10
  module Ocra
11
11
  Warden::Manager.serialize_into_session { |user| user.id }
12
- Warden::Manager.serialize_from_session { |id| User.get(id) }
12
+ Warden::Manager.serialize_from_session { |id| config.user_class.get(id) }
13
13
 
14
14
  Warden::Strategies.add :ocra_verify, Strategies::OcraVerify
15
15
  Warden::Strategies.add :ocra_challenge, Strategies::OcraChallenge
@@ -4,7 +4,7 @@ module Warden
4
4
  attr_accessor :suite, :param_user_identifier, :param_response,
5
5
  :generate_challenge_method, :has_challenge_method,
6
6
  :user_finder_method, :user_shared_secret_method,
7
- :user_challenge_method, :user_class
7
+ :user_challenge_method, :user_class_name
8
8
 
9
9
  def initialize
10
10
  self.suite = 'OCRA-1:HOTP-SHA1-6:QN08'
@@ -15,7 +15,11 @@ module Warden
15
15
  self.user_finder_method = 'find_by_email!'
16
16
  self.user_shared_secret_method = 'shared_secret'
17
17
  self.user_challenge_method = 'challenge'
18
- self.user_class = 'User'
18
+ self.user_class_name = 'User'
19
+ end
20
+
21
+ def user_class
22
+ Kernel.const_get(user_class_name)
19
23
  end
20
24
  end
21
25
 
@@ -6,26 +6,22 @@ module Warden
6
6
  params[Warden::Ocra::config.param_user_identifier]
7
7
  end
8
8
 
9
- def user_class
10
- Kernel.const_get(Warden::Ocra::config.user_class)
11
- end
12
-
13
9
  def generate_challenge
14
- user_class.send(
10
+ Warden::Ocra::config.user_class.send(
15
11
  Warden::Ocra::config.generate_challenge_method,
16
12
  user_param
17
13
  )
18
14
  end
19
15
 
20
16
  def has_challenge?
21
- user_param && user_class.send(
17
+ user_param && Warden::Ocra::config.user_class.send(
22
18
  Warden::Ocra::config.has_challenge_method,
23
19
  user_param
24
20
  )
25
21
  end
26
22
 
27
23
  def find_user
28
- user_class.send(
24
+ Warden::Ocra::config.user_class.send(
29
25
  Warden::Ocra::config.user_finder_method,
30
26
  user_param
31
27
  )
@@ -1,5 +1,5 @@
1
1
  module Warden
2
2
  module Ocra
3
- VERSION = "0.1.0"
3
+ VERSION = "0.1.1"
4
4
  end
5
5
  end
@@ -4,8 +4,8 @@ describe Warden::Ocra do
4
4
  context "#configure" do
5
5
  context "should override default value" do
6
6
  context "all strategies" do
7
- it "user_class" do
8
- Warden::Ocra.config.user_class = 'Profile'
7
+ it "user_class_name" do
8
+ Warden::Ocra.config.user_class_name = 'Profile'
9
9
 
10
10
  user = User.new
11
11
  user.stub(:shared_secret).and_return('0000')
@@ -19,7 +19,7 @@ describe Warden::Ocra do
19
19
  strategy.authenticate!
20
20
  strategy.valid?
21
21
 
22
- Warden::Ocra.config.user_class = 'User'
22
+ Warden::Ocra.config.user_class_name = 'User'
23
23
  end
24
24
  end
25
25
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: warden-ocra
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -145,7 +145,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
145
145
  version: '0'
146
146
  segments:
147
147
  - 0
148
- hash: 586295458760637074
148
+ hash: -3088463483733148843
149
149
  required_rubygems_version: !ruby/object:Gem::Requirement
150
150
  none: false
151
151
  requirements:
@@ -154,7 +154,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
154
154
  version: '0'
155
155
  segments:
156
156
  - 0
157
- hash: 586295458760637074
157
+ hash: -3088463483733148843
158
158
  requirements: []
159
159
  rubyforge_project:
160
160
  rubygems_version: 1.8.25