关于devise结合github通过omniauth登录_Ruby_编程开发_程序员俱乐部

中国优秀的程序员网站程序员频道CXYCLUB技术地图
热搜:
更多>>
 
您所在的位置: 程序员俱乐部 > 编程开发 > Ruby > 关于devise结合github通过omniauth登录

关于devise结合github通过omniauth登录

 2013/7/10 4:36:37  夜鸣猪  程序员俱乐部  我要评论(0)
  • 摘要:最近写了个github帐户登录Demo:https://github.com/yankforce/devise_omniauth_github演示项目地址:http://devise-github.herokuapp.comBASIC版本,只是githubomniauth,可以参考这个https://github.com/bay6/omniauth-github-exampledemo:http://github-ominiauth.herokuapp.com主要遇到问题
  • 标签:结合 Github
最近写了个github帐户登录Demo:
https://github.com/yankforce/devise_omniauth_github


演示项目地址:

http://devise-github.herokuapp.com


BASIC版本,只是github omniauth,可以参考这个
https://github.com/bay6/omniauth-github-example
demo:
http://github-ominiauth.herokuapp.com

主要遇到问题:
class="ruby" name="code">
No route matches “/users/sign_out” devise rails 3

<div id="user_nav">
    <% if user_signed_in? %>
        Signed in as <%= current_user.email %>. This cannot be cheese?
        <%= link_to 'Sign out', destroy_user_session_path %>
    <% else %>
        <%= link_to 'Register', new_user_registration_path %> or <%= link_to 'Sign in', new_user_session_path %>
    <% end %>
</div>

忘了delete方法

<%= link_to "Sign out", destroy_user_session_path, :method => :delete %>



重写登录成功,退出路径hook
def after_sign_in_path_for(resource)
 current_user_path
end

def after_sign_out_path_for(resource_or_scope)
  request.referrer
end



devise默认call back地址
http://yourdomain.users/auth/github/callback

问题三

Undefined method omniauth_authorize_path

The fix, or at least the one that worked for me:
replace:
    omniauth_authorize_path(resource_name, provider)
with
    user_omniauth_authorize_path(provider)


解决办法:
#删除config/initializers/omniauth.rb 
#添加到config/initializers/devise.rb
config.omniauth :github, CONFIG[:facebook_key], CONFIG[:facebook_secret]


总的来说devise的omniauth不能用omniauth的传统配置
https://github.com/plataformatec/devise/wiki/OmniAuth%3A-Overview
不是https://github.com/intridea/omniauth
发表评论
用户名: 匿名