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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0d2a587c796b1c63782f0857c794316e1f0d2024
4
- data.tar.gz: 76f395b427c7c63b266dddb2c68f1dc697b21634
3
+ metadata.gz: 3b309f8c673b807d4fc3495e08cd905d519b46f2
4
+ data.tar.gz: 36ca9bc0adb509b2a9b8d498e34783ac25277587
5
5
  SHA512:
6
- metadata.gz: 5f9561cb2a41dfbcb2220ab48f4684984a0dc8356fd02d42ecfa07c0fc24928b355ae992f88be9d85ff2d38c80124483e1b8a97f87cfa2312e25c100acf18ca9
7
- data.tar.gz: 7eb08462cae8ac9643cbb108f9b96080849121f3a24dd48f48bc1a841429051dd4ac36da2648112022ac23d076892b92c072495fc9719e9a0953dfbf40e3cd6a
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), 'data-no-turbolink' => true do
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), 'data-no-turbolink' => true do
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), 'data-no-turbolink' => true do
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 prepare_path
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
- nil
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
@@ -1,5 +1,5 @@
1
1
  module Omniauth
2
2
  module MultipleProviders
3
- VERSION = "0.0.2"
3
+ VERSION = "0.0.3"
4
4
  end
5
5
  end
@@ -21,6 +21,7 @@ Gem::Specification.new do |spec|
21
21
  spec.add_development_dependency "bundler", "~> 1.3"
22
22
  spec.add_development_dependency "rake"
23
23
 
24
+ spec.add_dependency 'devise'
24
25
  spec.add_dependency 'omniauth'
25
26
  spec.add_dependency 'activesupport'
26
27
  end
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.2
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-22 00:00:00.000000000 Z
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