Question

I would like to create URL's that, if the user clicks, log them in automatically without having to supply a username and or password.

Anyone know how to accomplish this in Devise with Rails 3? Preferrable the URL's that are generated to login a user are as short as possible.

Was it helpful?

Solution

If you are using devise you can use token authenticatable.

Check this out for more info http://zyphmartin.com/blog/simple-auth-token-example-with-devise

OTHER TIPS

Have you considered using cookies? Have a column autologin in your users table, with the contents of that field generated upon first manual login. Set the contents of this field in a cookie and you are done - simply check for the cookie upon entering any page of your application and find a user based on the value in the cookie. Instead of using a cookie, of course, you can pass it through URL. Moreover, you can set that in the session variable, so that the user stays logged in during a session, but must log in again when visiting next time.

On a side note: personally, I believe you should never pass a username and password through a URL.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top