简体   繁体   English

使用authlogic和omniauth-facebook登录到Facebook

[英]Login with Facebook with authlogic and omniauth-facebook

I have user_session_controller. 我有user_session_controller。 Here i have used authlogic gem and 'omniauth-facebook' gem. 在这里,我使用了authlogic gem和'omniauth-facebook'gem。 and i want that user can login with facebook in my site. 并且我希望该用户可以在我的网站上使用Facebook登录。 I am totally new. 我是全新的。 Please guide me how to modify this code for login with facebook. 请指导我如何修改此代码以使用Facebook登录。

def create
    @user_session = UserSession.new(params[:user_session],true)
    if @user_session.save
        flash[:notice] = "Login successful!"
        unless cookies[:last_visited].nil?
            set_last_visited
        end

        cookies.permanent[:last_visited] = Time.now
        if params[:remember_me]
            user = @user_session.user
        user.update_attributes(:remember_token => create_remember_token)
            cookies[:remember_token] = { :value => user.remember_token, :expires => 24.weeks.from_now }
        end
        redirect_back_or_default users_url(@current_user)
    else
        flash[:error]="invalid login and password"
        render :action => :new
    end
end

Please take a look to my response on: 请看一下我对以下内容的回复:

Devise, Omniauth and Facebook integration session error Devise,Omniauth和Facebook集成会话错误

You can find more tutorial on: 您可以在以下位置找到更多教程:

https://github.com/plataformatec/devise/wiki/OmniAuth:-Overview https://github.com/plataformatec/devise/wiki/OmniAuth:-概述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM