OpenID auth using Launchpad and Stackexchange works
This commit is contained in:
parent
2c135e1ca0
commit
4bad4d3a36
7 changed files with 38 additions and 86 deletions
|
|
@ -1,23 +1,25 @@
|
|||
class User < ApplicationRecord
|
||||
|
||||
# Include default devise modules. Others available are:
|
||||
# :confirmable, :lockable, :timeoutable and :omniauthable
|
||||
devise :database_authenticatable,
|
||||
# :registerable,
|
||||
:recoverable,
|
||||
# :recoverable,
|
||||
# :rememberable,
|
||||
:trackable,
|
||||
# :validatable,
|
||||
:timeoutable,
|
||||
# :lockable,
|
||||
:omniauthable, :omniauth_providers => [:google_oauth2, :launchpad, :amazon]
|
||||
# :omniauthable, :omniauth_providers => [:launchpad, :google]
|
||||
:omniauthable, :omniauth_providers => [:launchpad,:stackexchange]
|
||||
|
||||
|
||||
def self.from_omniauth(auth)
|
||||
where(provider: auth.provider, uid: auth.uid).first_or_create do |user|
|
||||
where(provider: auth.provider, email: auth.info.email).first_or_create do |user|
|
||||
user.provider = auth.provider
|
||||
user.uid = auth.uid
|
||||
user.email = auth.info.email
|
||||
user.name = auth.info.name
|
||||
# Set a random password
|
||||
user.password = Devise.friendly_token[0,20]
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue