关于devise结合github通过omniauth登录

最近写了个github帐户登录Demo:
[url]https://github.com/yankforce/devise_omniauth_github[/url]


演示项目地址:

[url]http://devise-github.herokuapp.com[/url]


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

主要遇到问题:

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地址
[url]http://yourdomain.users/auth/github/callback[/url]

[color=olive]问题三[/color]


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的传统配置
[url]https://github.com/plataformatec/devise/wiki/OmniAuth%3A-Overview[/url]
不是[url]https://github.com/intridea/omniauth[/url]
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值