rails_cerberus 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/lib/cerberus/controller_helpers.rb +1 -1
- data/lib/cerberus/identity.rb +1 -1
- data/lib/cerberus/sessions_controller.rb +1 -2
- data/lib/cerberus/version.rb +1 -1
- data/lib/cerberus.rb +9 -5
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7ec9ebc2b0b15ab9162c41b48d1362329ee87356
|
4
|
+
data.tar.gz: 2319001da788f897595fcecffbbb5686bc6e0201
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 31ec585915f081d467c849ad8dcfe9044314be5b3790baef87e309ec6e3c3b438f68b1eb5a463285e36292fdaaf879d58058d7006164396893fa5c633f088c62
|
7
|
+
data.tar.gz: 3bd83c1a6d79350bef98fafc61e46cee0703108ee28e241202eaf9ccbc757a35e00cc9618ed260c4184b6b128d72d557f2bdbcc19310537381c086a8d9293d11
|
data/lib/cerberus/identity.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
class Cerberus::Identity < ActiveRecord::Base
|
2
2
|
self.table_name = 'cerberus_identities'
|
3
|
-
belongs_to :user, class_name: Cerberus.config[:
|
3
|
+
belongs_to :user, class_name: Cerberus.config[:identities][:user_class_name]
|
4
4
|
|
5
5
|
validates :provider, :uid, presence: true
|
6
6
|
end
|
@@ -3,7 +3,7 @@ require 'cerberus/identity'
|
|
3
3
|
class Cerberus::SessionsController < ActionController::Base
|
4
4
|
def create
|
5
5
|
identity = Cerberus::Identity.find_or_create_by! auth.slice(:provider, :uid)
|
6
|
-
identity.user ||= Cerberus.config[:identities][:user_class_name].constantize.find_or_create_by! auth
|
6
|
+
identity.user ||= Cerberus.config[:identities][:user_class_name].constantize.find_or_create_by! email: auth[:info][:email]
|
7
7
|
identity.save
|
8
8
|
|
9
9
|
session[:user_id] = identity.user.id
|
@@ -19,4 +19,3 @@ class Cerberus::SessionsController < ActionController::Base
|
|
19
19
|
|
20
20
|
def auth() env['omniauth.auth'] end
|
21
21
|
end
|
22
|
-
|
data/lib/cerberus/version.rb
CHANGED
data/lib/cerberus.rb
CHANGED
@@ -7,13 +7,17 @@ module Cerberus
|
|
7
7
|
def self.root() File.dirname(__dir__) end
|
8
8
|
def self.config
|
9
9
|
config_defaults.deep_merge(
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
10
|
+
begin
|
11
|
+
YAML.load_file(
|
12
|
+
File.join(Dir.pwd, 'config/cerberus.yaml')
|
13
|
+
)
|
14
|
+
rescue Errno::ENOENT
|
15
|
+
{}
|
16
|
+
end
|
17
|
+
).with_indifferent_access
|
14
18
|
end
|
15
19
|
def self.config_defaults
|
16
|
-
{
|
20
|
+
{ identities: { user_class_name: 'User' } }
|
17
21
|
end
|
18
22
|
end
|
19
23
|
|