facemock-oauth 0.0.4 → 0.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.md +2 -2
- data/lib/facemock/oauth/authentication.rb +4 -0
- data/lib/facemock/oauth/callback_hook.rb +4 -0
- data/lib/facemock/oauth/login.rb +4 -0
- data/lib/facemock/oauth/login_hook.rb +6 -2
- data/lib/facemock/oauth/rack_middleware.rb +0 -4
- data/lib/facemock/oauth/version.rb +1 -1
- data/spec/facemock/oauth/login_hook_spec.rb +11 -10
- data/spec/facemock/oauth_spec.rb +1 -1
- metadata +4 -4
data/README.md
CHANGED
@@ -39,7 +39,7 @@ for Rails
|
|
39
39
|
|
40
40
|
$ vi config/environments/development.rb
|
41
41
|
|
42
|
-
Facemock::OAuth::LoginHook.
|
42
|
+
Facemock::OAuth::LoginHook.paths = [ '/facebook/sign_in', '/user/facebook/sign_in' ]
|
43
43
|
Facemock::OAuth::CallbackHook.path = '/users/facemock/auth/callback'
|
44
44
|
|
45
45
|
config.middleware.use Facemock::OAuth::LoginHook
|
@@ -54,7 +54,7 @@ for Sinatra
|
|
54
54
|
require 'sinatra'
|
55
55
|
require 'facemock-oauth'
|
56
56
|
|
57
|
-
Facemock::OAuth::LoginHook.
|
57
|
+
Facemock::OAuth::LoginHook.paths = [ '/facebook/sign_in', '/user/facebook/sign_in' ]
|
58
58
|
Facemock::OAuth::CallbackHook.path = '/users/facemock/auth/callback'
|
59
59
|
|
60
60
|
use Facemock::OAuth::LoginHook
|
data/lib/facemock/oauth/login.rb
CHANGED
@@ -1,12 +1,16 @@
|
|
1
1
|
module Facemock
|
2
2
|
module OAuth
|
3
3
|
class LoginHook < RackMiddleware
|
4
|
+
class << self
|
5
|
+
attr_accessor :paths
|
6
|
+
end
|
7
|
+
|
4
8
|
DEFAULT_PATH = "/sign_in"
|
5
|
-
@
|
9
|
+
@paths = [ DEFAULT_PATH ]
|
6
10
|
|
7
11
|
def call(env)
|
8
12
|
res = super
|
9
|
-
if env["PATH_INFO"]
|
13
|
+
if LoginHook.paths.include?(env["PATH_INFO"])
|
10
14
|
code = 302
|
11
15
|
body = []
|
12
16
|
header = { "Content-Type" => "text/html;charset=utf-8",
|
@@ -15,18 +15,19 @@ describe Facemock::OAuth::LoginHook do
|
|
15
15
|
end
|
16
16
|
|
17
17
|
describe '.path' do
|
18
|
-
subject { Facemock::OAuth::LoginHook.
|
19
|
-
it { is_expected.to eq path }
|
18
|
+
subject { Facemock::OAuth::LoginHook.paths }
|
19
|
+
it { is_expected.to eq [ path ] }
|
20
20
|
end
|
21
21
|
|
22
22
|
describe '.path=' do
|
23
23
|
context 'with "/test"' do
|
24
24
|
before { @path = "/test" }
|
25
|
-
after { Facemock::OAuth::LoginHook.
|
25
|
+
after { Facemock::OAuth::LoginHook.paths = [ path ] }
|
26
26
|
|
27
27
|
it 'should set class instance variable path' do
|
28
|
-
Facemock::OAuth::LoginHook.
|
29
|
-
expect(Facemock::OAuth::LoginHook.
|
28
|
+
Facemock::OAuth::LoginHook.paths << @path
|
29
|
+
expect(Facemock::OAuth::LoginHook.paths).to include path
|
30
|
+
expect(Facemock::OAuth::LoginHook.paths).to include @path
|
30
31
|
end
|
31
32
|
end
|
32
33
|
end
|
@@ -48,7 +49,7 @@ describe Facemock::OAuth::LoginHook do
|
|
48
49
|
before { @path = '/' }
|
49
50
|
end
|
50
51
|
|
51
|
-
describe "GET '/
|
52
|
+
describe "GET '/sign_in'" do
|
52
53
|
context 'when path is default value', assert: :RedirectToFacemockSignin do
|
53
54
|
before { @path = path }
|
54
55
|
end
|
@@ -56,9 +57,9 @@ describe Facemock::OAuth::LoginHook do
|
|
56
57
|
context 'when path variable set ather path', assert: :RequestSuccess do
|
57
58
|
before do
|
58
59
|
@path = path
|
59
|
-
Facemock::OAuth::LoginHook.
|
60
|
+
Facemock::OAuth::LoginHook.paths = [ "/test" ]
|
60
61
|
end
|
61
|
-
after { Facemock::OAuth::LoginHook.
|
62
|
+
after { Facemock::OAuth::LoginHook.paths = [ path ] }
|
62
63
|
end
|
63
64
|
end
|
64
65
|
|
@@ -66,9 +67,9 @@ describe Facemock::OAuth::LoginHook do
|
|
66
67
|
context "when path variable set '/test'", assert: :RedirectToFacemockSignin do
|
67
68
|
before do
|
68
69
|
@path = "/test"
|
69
|
-
Facemock::OAuth::LoginHook.
|
70
|
+
Facemock::OAuth::LoginHook.paths = [ @path ]
|
70
71
|
end
|
71
|
-
after { Facemock::OAuth::LoginHook.
|
72
|
+
after { Facemock::OAuth::LoginHook.paths = [ path ] }
|
72
73
|
end
|
73
74
|
end
|
74
75
|
end
|
data/spec/facemock/oauth_spec.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: facemock-oauth
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
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: 2014-09-
|
12
|
+
date: 2014-09-30 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: facemock
|
@@ -203,7 +203,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
203
203
|
version: '0'
|
204
204
|
segments:
|
205
205
|
- 0
|
206
|
-
hash:
|
206
|
+
hash: 422700096564625871
|
207
207
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
208
208
|
none: false
|
209
209
|
requirements:
|
@@ -212,7 +212,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
212
212
|
version: '0'
|
213
213
|
segments:
|
214
214
|
- 0
|
215
|
-
hash:
|
215
|
+
hash: 422700096564625871
|
216
216
|
requirements: []
|
217
217
|
rubyforge_project:
|
218
218
|
rubygems_version: 1.8.25
|