devise-multi_auth 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Rakefile +1 -1
- data/app/controllers/devise/multi_auth/authentications_controller.rb +1 -0
- data/lib/devise/multi_auth.rb +20 -0
- data/lib/devise/multi_auth/version.rb +1 -1
- data/lib/devise_multi_auth.rb +1 -20
- data/lib/generators/devise/multi_auth/install/install_generator.rb +7 -4
- metadata +3 -3
- data/lib/generators/devise/multi_auth/install/templates/devise_multi_auth_initializer.rb.erb +0 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 93c42eb9fd43d69aaff590dd248b90cf5d7380f1
|
4
|
+
data.tar.gz: 01b1dccb4afa06f5217dc06fc229e04dec18af0c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b2e715ed0ddcdac20aa11a48e74b5d6bf91e509303804ba6ea64f2e7b127d2659a94efb54cebd4836f0ba121bdab4c4b45ba74649a9e3a0d63afdaeb5d1cb179
|
7
|
+
data.tar.gz: c86669718c3fe9b35f50b44e831dc402be045bec9c29dadbff8028a3f1a1cf1e38ac5c2a54fa522583a37d072f4028b4561e729fbd9d0d0434d4569c60c404ae
|
data/Rakefile
CHANGED
@@ -13,6 +13,7 @@ module Devise::MultiAuth
|
|
13
13
|
omni = request.env["omniauth.auth"]
|
14
14
|
if @user = Authentication.find_user_by_provider_and_uid(omni['provider'], omni['uid'])
|
15
15
|
set_flash_message(:notice, :success, kind: omni['provider']) if is_navigational_format?
|
16
|
+
Devise::MultiAuth.capture_successful_external_authentication(@user, omni)
|
16
17
|
sign_in_and_redirect @user, event: :authentication
|
17
18
|
else
|
18
19
|
session["devise.auth_data"] = request.env["omniauth.auth"].except('extra')
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require "devise/multi_auth/engine"
|
2
|
+
|
3
|
+
module Devise::MultiAuth
|
4
|
+
module_function
|
5
|
+
|
6
|
+
def capture_successful_external_authentication(user, auth, config = {})
|
7
|
+
service = config.fetch(:service) { CaptureSuccessfulExternalAuthentication }
|
8
|
+
service.call(user, auth)
|
9
|
+
end
|
10
|
+
|
11
|
+
def oauth_client_for(provider_name, config = {})
|
12
|
+
default_args = Devise.omniauth_configs.fetch(provider_name.to_sym).args.dup
|
13
|
+
default_options = default_args.extract_options!
|
14
|
+
options = config.fetch(:options) { default_options[:client_options] || {} }
|
15
|
+
client_id = config.fetch(:client_id) { default_args[0] }
|
16
|
+
secret = config.fetch(:secret) { default_args[1] }
|
17
|
+
OAuth2::Client.new(client_id, secret, options)
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
data/lib/devise_multi_auth.rb
CHANGED
@@ -1,21 +1,2 @@
|
|
1
1
|
require "devise"
|
2
|
-
require "devise/multi_auth
|
3
|
-
|
4
|
-
module Devise::MultiAuth
|
5
|
-
module_function
|
6
|
-
|
7
|
-
def capture_successful_external_authentication(user, auth, config = {})
|
8
|
-
service = config.fetch(:service) { CaptureSuccessfulExternalAuthentication }
|
9
|
-
service.call(user, auth)
|
10
|
-
end
|
11
|
-
|
12
|
-
def oauth_client_for(provider_name, config = {})
|
13
|
-
default_args = Devise.omniauth_configs.fetch(provider_name.to_sym).args.dup
|
14
|
-
default_options = default_args.extract_options!
|
15
|
-
options = config.fetch(:options) { default_options[:client_options] || {} }
|
16
|
-
client_id = config.fetch(:client_id) { default_args[0] }
|
17
|
-
secret = config.fetch(:secret) { default_args[1] }
|
18
|
-
OAuth2::Client.new(client_id, secret, options)
|
19
|
-
end
|
20
|
-
|
21
|
-
end
|
2
|
+
require "devise/multi_auth"
|
@@ -5,6 +5,7 @@ module Devise::MultiAuth
|
|
5
5
|
source_root File.expand_path('../templates', __FILE__)
|
6
6
|
|
7
7
|
class_option :install_devise, default: false, type: :boolean
|
8
|
+
class_option :skip_migrate, default: false, type: :boolean
|
8
9
|
|
9
10
|
def install_devise
|
10
11
|
if options[:install_devise]
|
@@ -14,16 +15,18 @@ module Devise::MultiAuth
|
|
14
15
|
end
|
15
16
|
|
16
17
|
def install_authentications_controller
|
18
|
+
gem "omniauth-github"
|
17
19
|
routing_code = %(, controllers: { omniauth_callbacks: 'devise/multi_auth/authentications' }\n)
|
18
20
|
insert_into_file 'config/routes.rb', routing_code, { :after => /devise_for :users/, :verbose => false }
|
19
21
|
end
|
20
22
|
|
21
|
-
def install_warden_initializer
|
22
|
-
template('devise_multi_auth_initializer.rb.erb', 'config/initializers/devise_multi_auth_initializer.rb')
|
23
|
-
end
|
24
|
-
|
25
23
|
def install_migrations
|
26
24
|
rake 'devise_multi_auth:install:migrations'
|
25
|
+
if ! options[:skip_migrate]
|
26
|
+
rake 'db:migrate'
|
27
|
+
end
|
27
28
|
end
|
29
|
+
|
28
30
|
end
|
31
|
+
|
29
32
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: devise-multi_auth
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- jeremy.n.friesen@gmail.com
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-03-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -149,10 +149,10 @@ files:
|
|
149
149
|
- db/migrate/20140204141526_create_authentications.rb
|
150
150
|
- lib/devise/multi_auth/engine.rb
|
151
151
|
- lib/devise/multi_auth/version.rb
|
152
|
+
- lib/devise/multi_auth.rb
|
152
153
|
- lib/devise-multi_auth.rb
|
153
154
|
- lib/devise_multi_auth.rb
|
154
155
|
- lib/generators/devise/multi_auth/install/install_generator.rb
|
155
|
-
- lib/generators/devise/multi_auth/install/templates/devise_multi_auth_initializer.rb.erb
|
156
156
|
- lib/tasks/devise-multi_auth_tasks.rake
|
157
157
|
- LICENSE
|
158
158
|
- Rakefile
|