forked from External/greenlight
add users controller and intermediate username step
This commit is contained in:
@ -1,10 +1,13 @@
|
||||
class User < ApplicationRecord
|
||||
|
||||
validates :username, uniqueness: true
|
||||
|
||||
def self.from_omniauth(auth_hash)
|
||||
user = find_or_create_by(uid: auth_hash['uid'], provider: auth_hash['provider'])
|
||||
user.username = self.send("#{auth_hash['provider']}_username", auth_hash) rescue nil
|
||||
user.name = auth_hash['info']['name']
|
||||
user.save!
|
||||
user = find_or_initialize_by(uid: auth_hash['uid'], provider: auth_hash['provider'])
|
||||
unless user.persisted?
|
||||
# user.username = self.send("#{auth_hash['provider']}_username", auth_hash) rescue nil
|
||||
user.name = auth_hash['info']['name']
|
||||
end
|
||||
user
|
||||
end
|
||||
|
||||
|
Reference in New Issue
Block a user