mirror of
https://github.com/danbee/my-images
synced 2025-03-04 08:49:05 +00:00
Refactor user OAuth stuff.
This commit is contained in:
parent
3a8ec5d85a
commit
ec0f64938b
@ -2,14 +2,14 @@ class User < ActiveRecord::Base
|
|||||||
dragonfly_accessor :avatar
|
dragonfly_accessor :avatar
|
||||||
|
|
||||||
def self.find_or_create_from_auth(auth)
|
def self.find_or_create_from_auth(auth)
|
||||||
user = User.find_by(provider: auth.provider, uid: auth.uid)
|
find_by(auth.slice(:provider, :uid)) || create_from_auth(auth)
|
||||||
if user.blank?
|
end
|
||||||
user = User.create(provider: auth.provider,
|
|
||||||
uid: auth.uid,
|
def self.create_from_auth(auth)
|
||||||
username: auth.info.nickname,
|
create(provider: auth.provider,
|
||||||
name: auth.info.name,
|
uid: auth.uid,
|
||||||
avatar_url: auth.info.image)
|
username: auth.info.nickname,
|
||||||
end
|
name: auth.info.name,
|
||||||
user
|
avatar_url: auth.info.image)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user