omniauth-multiple_providers 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +10 -5
- data/app/controllers/omniauth/multiple_providers_controller.rb +4 -1
- data/lib/omniauth/multiple_providers/models/concerns/omniauthable.rb +8 -2
- data/lib/omniauth/multiple_providers/version.rb +1 -1
- data/omniauth-multiple_providers.gemspec +1 -0
- metadata +16 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3b309f8c673b807d4fc3495e08cd905d519b46f2
|
4
|
+
data.tar.gz: 36ca9bc0adb509b2a9b8d498e34783ac25277587
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 687527de65efb1d720bee91f874daa15a1fe696452062ed740987d71d5a7df753255cb30ddb497f94d387ad09ace2f6766a8eb327eb19415250d9ceb4f5041d6
|
7
|
+
data.tar.gz: a533d6f7cab5e352e90f0ce3f39e9512629c36a17582510f872b6403bbaefe909e7be72b9c4cc8db0eb77dca7044648f56e0977bc86918d95bdf98fad63b8a70
|
data/README.md
CHANGED
@@ -41,6 +41,8 @@ Or install it yourself as:
|
|
41
41
|
|
42
42
|
$ gem install omniauth-multiple_providers
|
43
43
|
|
44
|
+
## Usage
|
45
|
+
|
44
46
|
`app/models/user.rb` (generated by Devise) do not use `:omniauthable`.
|
45
47
|
|
46
48
|
``` ruby
|
@@ -60,21 +62,19 @@ $ rails generate omniauth:multiple_providers:install
|
|
60
62
|
$ rake db:migrate # => create provider_users table
|
61
63
|
```
|
62
64
|
|
63
|
-
## Usage
|
64
|
-
|
65
65
|
You can use `new_omniauth_path(provider: :provider_name)`, and It redirect_to `/auth/:provider_name`.
|
66
66
|
And automatically receive callback, and Save to `ProviderUser`(app/models/provider_user.rb).
|
67
67
|
|
68
68
|
``` haml
|
69
69
|
%ul
|
70
70
|
%li
|
71
|
-
= link_to new_omniauth_path(provider: :twitter)
|
71
|
+
= link_to new_omniauth_path(provider: :twitter) do
|
72
72
|
Signup with Twitter
|
73
73
|
%li
|
74
|
-
= link_to new_omniauth_path(provider: :facebook)
|
74
|
+
= link_to new_omniauth_path(provider: :facebook) do
|
75
75
|
Signup with Facebook
|
76
76
|
%li
|
77
|
-
= link_to new_omniauth_path(provider: :github)
|
77
|
+
= link_to new_omniauth_path(provider: :github) do
|
78
78
|
Signup with Github
|
79
79
|
```
|
80
80
|
|
@@ -85,6 +85,11 @@ And if you remove connection to Providers,
|
|
85
85
|
cancel connection
|
86
86
|
```
|
87
87
|
|
88
|
+
## TODO
|
89
|
+
|
90
|
+
- Drop Dependency of Devise
|
91
|
+
- Configuratable with initializer
|
92
|
+
|
88
93
|
## Contributing
|
89
94
|
|
90
95
|
1. Fork it
|
@@ -1,5 +1,7 @@
|
|
1
1
|
module Omniauth
|
2
2
|
class MultipleProvidersController < ApplicationController
|
3
|
+
|
4
|
+
# PATH: new_omniauth_path(provider: 'twitter')
|
3
5
|
def new
|
4
6
|
if %w[twitter github google_oauth2 facebook].include?(params[:provider])
|
5
7
|
redirect_to "/auth/#{params[:provider]}"
|
@@ -13,7 +15,7 @@ module Omniauth
|
|
13
15
|
if @user.new_record?
|
14
16
|
redirect_to new_user_session_path, flash: {error: "ユーザデータの保存に失敗しました:#{@user.errors.full_messages.join(', ')}"}
|
15
17
|
elsif @user.email.blank?
|
16
|
-
redirect_to
|
18
|
+
redirect_to new_user_registration_path(@user)
|
17
19
|
else
|
18
20
|
sign_in(@user)
|
19
21
|
redirect_to root_path, notice: 'OK'
|
@@ -24,6 +26,7 @@ module Omniauth
|
|
24
26
|
redirect_to root_path, flash: {error: 'OAuth認証に失敗しました'}
|
25
27
|
end
|
26
28
|
|
29
|
+
# PATH: omniauth_path('twitter'), method: :delete
|
27
30
|
def destroy
|
28
31
|
if up = current_user.provider_users.find_by(provider: params[:id])
|
29
32
|
up.destroy
|
@@ -48,12 +48,18 @@ module Omniauth
|
|
48
48
|
if up = ProviderUser.find_by(uid: auth['uid'], provider: auth['provider'])
|
49
49
|
up.user
|
50
50
|
else
|
51
|
-
|
51
|
+
# Hmmm...
|
52
|
+
# FIXME to be configuratable
|
53
|
+
# Do this If you trust provider email
|
54
|
+
if user = User.find_by(email: auth['email'])
|
55
|
+
user
|
56
|
+
else
|
57
|
+
nil
|
58
|
+
end
|
52
59
|
end
|
53
60
|
end
|
54
61
|
|
55
62
|
def create_by_oauth(auth)
|
56
|
-
logger.debug "##### Auth Hash: #{auth.to_json}"
|
57
63
|
case auth['provider']
|
58
64
|
when 'twitter'
|
59
65
|
# Twitter not give me email from api
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: omniauth-multiple_providers
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Takuya Kato
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-01-
|
11
|
+
date: 2014-01-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -38,6 +38,20 @@ dependencies:
|
|
38
38
|
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: devise
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
41
55
|
- !ruby/object:Gem::Dependency
|
42
56
|
name: omniauth
|
43
57
|
requirement: !ruby/object:Gem::Requirement
|