Skip to content

Commit a6509c2

Browse files
Update User model with class method from Points
1 parent 2dfc983 commit a6509c2

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

app/models/ombu_labs/auth/user.rb

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,20 @@
11
module OmbuLabs::Auth
22
class User < ApplicationRecord
3+
self.table_name = "users"
4+
35
# Include default devise modules. Others available are:
46
# :confirmable, :lockable, :timeoutable
57
devise :database_authenticatable, :registerable,
6-
:recoverable, :rememberable, :trackable,
7-
:validatable, :omniauthable
8+
:recoverable, :rememberable, :trackable,
9+
:validatable, :omniauthable
10+
11+
def self.from_omniauth(auth)
12+
user_attributes = {
13+
email: auth.info.email,
14+
name: auth.info.name,
15+
password: Devise.friendly_token[0, 20]
16+
}
17+
where(provider: auth.provider, uid: auth.uid).first_or_create.tap { |user| user.update(user_attributes) }
18+
end
819
end
920
end

0 commit comments

Comments
 (0)