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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7e5653c6e47c9306b5e19591351c5b0937366ba9
4
- data.tar.gz: a596e72507cbd2d9ce671f05a52af69bcb3a3710
3
+ metadata.gz: 7ec9ebc2b0b15ab9162c41b48d1362329ee87356
4
+ data.tar.gz: 2319001da788f897595fcecffbbb5686bc6e0201
5
5
  SHA512:
6
- metadata.gz: 03d0c1489afb0e700b74baf30f21bdddbc6a9767f66f1428378c884ed789a6c4fdde4695b993f01bce9b0bb9e528195fa5173709d92a4a0ccae324e2c52f3a7c
7
- data.tar.gz: d81b801e16ca79eaf34cc30c9200a248908a1c66a3d3a88774dfbb91f3803031a39bccdfa7de8df7273de7093a76baf98a15525b59e72e41d2a0a850363ab4de
6
+ metadata.gz: 31ec585915f081d467c849ad8dcfe9044314be5b3790baef87e309ec6e3c3b438f68b1eb5a463285e36292fdaaf879d58058d7006164396893fa5c633f088c62
7
+ data.tar.gz: 3bd83c1a6d79350bef98fafc61e46cee0703108ee28e241202eaf9ccbc757a35e00cc9618ed260c4184b6b128d72d557f2bdbcc19310537381c086a8d9293d11
@@ -6,7 +6,7 @@ module Cerberus::ControllerHelpers
6
6
  end
7
7
 
8
8
  def current_user
9
- Cerberus.config[:identity][:user_class_name]
9
+ Cerberus.config[:identities][:user_class_name]
10
10
  .constantize.find(session[:user_id]) if session[:user_id]
11
11
  end
12
12
  end
@@ -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[:identity][:user_class_name]
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.slice(:email)
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
-
@@ -1,3 +1,3 @@
1
1
  module Cerberus
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
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
- YAML.load_file(
11
- File.join(Dir.pwd, 'config/cerberus.yaml')
12
- ).with_indifferent_access
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
- { identity: { user_class_name: 'User' } }
20
+ { identities: { user_class_name: 'User' } }
17
21
  end
18
22
  end
19
23
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails_cerberus
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
  - Nicolas Oga