oa-core 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (2) hide show
  1. data/lib/omniauth/strategy.rb +16 -7
  2. metadata +4 -4
@@ -28,23 +28,24 @@ module OmniAuth
28
28
  @env = env
29
29
  @env['omniauth.strategy'] = self
30
30
 
31
- setup_phase
32
31
  return mock_call!(env) if OmniAuth.config.test_mode
33
32
 
34
33
  if current_path == request_path && OmniAuth.config.allowed_request_methods.include?(request.request_method.downcase.to_sym)
34
+ setup_phase
35
35
  if response = call_through_to_app
36
36
  response
37
37
  else
38
38
  if request.params['origin']
39
- env['rack.session']['omniauth.origin'] = request.params['origin']
39
+ @env['rack.session']['omniauth.origin'] = request.params['origin']
40
40
  elsif env['HTTP_REFERER'] && !env['HTTP_REFERER'].match(/#{request_path}$/)
41
- env['rack.session']['omniauth.origin'] = env['HTTP_REFERER']
41
+ @env['rack.session']['omniauth.origin'] = env['HTTP_REFERER']
42
42
  end
43
43
  request_phase
44
44
  end
45
45
  elsif current_path == callback_path
46
- env['omniauth.origin'] = session.delete('omniauth.origin')
47
- env['omniauth.origin'] = nil if env['omniauth.origin'] == ''
46
+ setup_phase
47
+ @env['omniauth.origin'] = session.delete('omniauth.origin')
48
+ @env['omniauth.origin'] = nil if env['omniauth.origin'] == ''
48
49
 
49
50
  callback_phase
50
51
  else
@@ -58,18 +59,26 @@ module OmniAuth
58
59
 
59
60
  def mock_call!(env)
60
61
  if current_path == request_path
62
+ setup_phase
61
63
  if response = call_through_to_app
62
64
  response
63
65
  else
64
- env['rack.session']['omniauth.origin'] = env['HTTP_REFERER']
66
+ if request.params['origin']
67
+ @env['rack.session']['omniauth.origin'] = request.params['origin']
68
+ elsif env['HTTP_REFERER'] && !env['HTTP_REFERER'].match(/#{request_path}$/)
69
+ @env['rack.session']['omniauth.origin'] = env['HTTP_REFERER']
70
+ end
65
71
  redirect(callback_path)
66
72
  end
67
73
  elsif current_path == callback_path
74
+ setup_phase
68
75
  mocked_auth = OmniAuth.mock_auth_for(name.to_sym)
69
76
  if mocked_auth.is_a?(Symbol)
70
77
  fail!(mocked_auth)
71
78
  else
72
79
  @env['omniauth.auth'] = mocked_auth
80
+ @env['omniauth.origin'] = session.delete('omniauth.origin')
81
+ @env['omniauth.origin'] = nil if env['omniauth.origin'] == ''
73
82
  call_app!
74
83
  end
75
84
  else
@@ -186,7 +195,7 @@ module OmniAuth
186
195
  self.env['omniauth.error'] = exception
187
196
  self.env['omniauth.error.type'] = message_key.to_sym
188
197
  self.env['omniauth.error.strategy'] = self
189
-
198
+
190
199
  OmniAuth.config.on_failure.call(self.env)
191
200
  end
192
201
  end
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: oa-core
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.2.0
5
+ version: 0.2.1
6
6
  platform: ruby
7
7
  authors:
8
8
  - Michael Bleigh
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2011-03-11 00:00:00 -06:00
13
+ date: 2011-04-05 00:00:00 -05:00
14
14
  default_executable:
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
@@ -135,7 +135,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
135
135
  requirements:
136
136
  - - ">="
137
137
  - !ruby/object:Gem::Version
138
- hash: -2071655923572517505
138
+ hash: 4230123318692405709
139
139
  segments:
140
140
  - 0
141
141
  version: "0"
@@ -144,7 +144,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
144
144
  requirements:
145
145
  - - ">="
146
146
  - !ruby/object:Gem::Version
147
- hash: -2071655923572517505
147
+ hash: 4230123318692405709
148
148
  segments:
149
149
  - 0
150
150
  version: "0"