开发者

How do I have devise / omniauth redirect to the page from which I signed in from?

I have the authentication through omniauth and that link is available on every page through layout/application.html.haml.

However, when they complete the omniauth authentication,开发者_JS百科 they all go to root.

How can I set it up so they redirect to the actual page from which they clicked on the authentication link (which takes them to the oauth provider).

Thanks


You can use request.env['omniauth.origin'].

See https://github.com/intridea/omniauth/wiki/Saving-User-Location


I see two options here:

1) Set a session variable on every page you could possibly sign in through like that:

session[:return_to] = request.fullpath

and redirect back to it after signing in:

redirect_to session[:return_to]

or

2) try

redirect_to :back

This depends on how you link your controller actions (haven't worked with omniauth, so I have no experience in that respect)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜