foyer 0.1.2 → 0.1.3
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.
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
MjdmZWViMTEyMzE0ODUzNDUxMTljMmEyYmIwZTExOTg0NjM5M2EyMA==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
YjBkOWM3NjNmYTk0MmVkZWRmMzkxOGU5YThmODMxYjcyN2M2YTZiYQ==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
ZGVkMTZmOGM5MjZjZmJjZWNiMzlhMDRhMDNlZGZlZTJlNmVjNDg5OWRlOGNi
|
10
|
+
Yjg1MGFhNDBlZDdjYjE4MGFlOTMxNDlkMDdjMDY4OWVmMzA0N2MxODFmYWUy
|
11
|
+
ZTVlZWJiNjM5MDFjYzVkZGZmODBjZjAxNmQzOTcyNWZjMTAxNWI=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
ZGFiNmEyMTliNDBkNjRlMjllYzA2ZTVmMmE3OWJlNDRiODEwNmMwZjVmNTM1
|
14
|
+
ODdhNzc3MjRlYjRkZWIzYjE1NzNmZjQ5ZTlhZmU5MWI3MDlhOWYxOWY0Y2M5
|
15
|
+
OGRlMTQzODg4ZjBiNmEwYmFjMTI2YjljY2ZkNmM0MzNhN2ZmM2M=
|
data/README.md
CHANGED
@@ -9,7 +9,19 @@ sign on server that is configured as an OmniAuth provider
|
|
9
9
|
|
10
10
|
## Setup and Configuration
|
11
11
|
|
12
|
-
|
12
|
+
Setup as normal the `omniauth` gem. Remember to include in `routes.rb` the
|
13
|
+
implementating controller action that will call the `sign_in` method:
|
14
|
+
|
15
|
+
```ruby
|
16
|
+
Rails.application.routes.draw do
|
17
|
+
get '/auth/:provider/callback', to: 'omniauth_callbacks#callback'
|
18
|
+
end
|
19
|
+
```
|
20
|
+
|
21
|
+
You may extend the provided `Foyer::OmniauthCallbacksController`, as described
|
22
|
+
later in this document, to facilitate the implementation.
|
23
|
+
|
24
|
+
Then in your ApplicationController:
|
13
25
|
|
14
26
|
```ruby
|
15
27
|
class ApplicationController < ActionController::Base
|
@@ -30,7 +42,7 @@ You can also configure the user finder in an initializer:
|
|
30
42
|
Foyer.user_finder = lambda { |user_id| ... }
|
31
43
|
```
|
32
44
|
|
33
|
-
|
45
|
+
Besides `Foyer.user_finder` there are some additional configuration
|
34
46
|
settings:
|
35
47
|
|
36
48
|
```ruby
|
@@ -47,7 +59,7 @@ Currently, the session is the only store available.
|
|
47
59
|
Once the setup is complete, you will have the following methods available in
|
48
60
|
controllers that include `Foyer::Controller::Helpers`:
|
49
61
|
```
|
50
|
-
|
62
|
+
authenticate_user! - Before filter that redirects unauthenticated users
|
51
63
|
to omniauth
|
52
64
|
|
53
65
|
sign_in(user) - Pass a user object to this method to sign that user in.
|
@@ -64,7 +76,7 @@ sign_out - Signs out the authenticated user by clearing the session
|
|
64
76
|
|
65
77
|
### In Views
|
66
78
|
|
67
|
-
`
|
79
|
+
`current_user` and `user_signed_in?` are available as helper methods
|
68
80
|
in views.
|
69
81
|
|
70
82
|
### Routes
|
@@ -104,7 +116,7 @@ You can inherit from it in your application.
|
|
104
116
|
|
105
117
|
Example:
|
106
118
|
```ruby
|
107
|
-
class
|
119
|
+
class OmniauthCallbacksController < Foyer::OmniauthCallbacksController
|
108
120
|
def callback
|
109
121
|
user = User.find_or_initialize_by(uid: auth_hash.uid.to_s) do |u|
|
110
122
|
u.email = auth_hash.info.email
|
data/lib/foyer/version.rb
CHANGED
@@ -30,10 +30,10 @@ describe Foyer::Controller::Helpers do
|
|
30
30
|
describe "#current_user" do
|
31
31
|
it "calls the user_finder method" do
|
32
32
|
@called = false
|
33
|
-
subject.user_session[:id] = '_'
|
33
|
+
subject.send(:user_session)[:id] = '_'
|
34
34
|
Foyer.user_finder = lambda { |_| @called = true }
|
35
35
|
|
36
|
-
subject.current_user
|
36
|
+
subject.send :current_user
|
37
37
|
|
38
38
|
expect(@called).to eq true
|
39
39
|
end
|
@@ -8,14 +8,14 @@ module Foyer
|
|
8
8
|
end
|
9
9
|
|
10
10
|
it "defaults to root path" do
|
11
|
-
expect(controller.after_sign_in_path).to eq('/')
|
11
|
+
expect(controller.send :after_sign_in_path).to eq('/')
|
12
12
|
end
|
13
13
|
|
14
14
|
it "returns omniauth.origin if available" do
|
15
15
|
origin = '/some_path'
|
16
16
|
@request.env['omniauth.origin'] = origin
|
17
17
|
|
18
|
-
expect(controller.after_sign_in_path).to eq(origin)
|
18
|
+
expect(controller.send :after_sign_in_path).to eq(origin)
|
19
19
|
end
|
20
20
|
end
|
21
21
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: foyer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jason Nochlin
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-02-
|
11
|
+
date: 2014-02-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|