开发者

restful_authentication hash problem in Rails

开发者 https://www.devze.com 2023-02-02 03:40 出处:网络
I work with restful_authentication on my website. Here\'s my problem: If I am not logged in and go the page http://mywebsite.com/something#coolHash

I work with restful_authentication on my website. Here's my problem:

If I am not logged in and go the page http://mywebsite.com/something#coolHash

I get 开发者_StackOverflow中文版redirected to http://mywebsite.com/session/new and I log in.

But after that I get redirected to http://mywebsite.com/something but without the Hash which would be very important.

Is there a possibility to solve this?


I don't think you can do this as part of restful_authentication's regular url-forwarding system, because the browser strips off the part after the # before sending the request to the server. So, if the server never sees #coolHash then it can't save it into the session and retrieve it later on, after the user logs in. This would be a problem whatever server-based authentication you were using since the server never sees #coolHash (have a look in your access logs to see what request urls are actually recieved to verify this).

You could potentially solve the problem with javascript, i'm not sure what the nicest way would be. But, my advice would be to change your approach so that you don't care if #coolHash is remembered or not (any after-the-hash stuff should just be an enhancement to basically-works-fine behaviour anyway). For example, use a param instead of putting stuff after the hash. The param will be stored automatically by restful authentication.

0

精彩评论

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