我正在尝试使用omniauth-reddit
在rails应用程序中实现reddit登录登录是成功的,但我不会在哪里出错
我的OmniauthCallbacksController.rb文件
class Users::OmniauthCallbacksController < Devise::OmniauthCallbacksController
def reddit_oauth2
@user = User.from_omniauth(request.env["omniauth.auth"])
sign_in_and_redirect root_path
end
我的用户模型
class User < ActiveRecord::Base
# Include default devise modules. Others available are:
# :confirmable, :lockable, :timeoutable and :omniauthable
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :trackable, :validatable
devise :omniauthable, :omniauth_providers => [:reddit]
def self.from_omniauth(auth)
where(provider: auth.provider,uid: auth.id).first_or_create do |user|
user.provider = auth.provider
user.id = auth.id
user.password = Devise.friendly_token[0,20]
end
end
end
can anybody suggest me scope or solution ??
先谢谢