Stephen Hsu
Stephen Hsu

Reputation: 5187

How to let Rails tell mobile applications that users signed in or not?

I'm developing a Rails application that use devise as the authentication solution. For web applications, users enter username and password in a form, Rails can render different pages after users signed in.

Now I'd like to use this framework to support mobile app. In this case, the mobile app needs to know whether the user enters correct username and password.

How should devise response to the mobile application, response headers or JSON inside body? Does devise support it?

Upvotes: 0

Views: 148

Answers (2)

Stephen Hsu
Stephen Hsu

Reputation: 5187

More tutorials:

http://blog.joshsoftware.com/2011/12/23/designing-rails-api-using-rabl-and-devise/

http://www.strukturedkaos.com/2011/09/19/soup-to-nuts-token-authentication-for-android-using-rails-3-devise/

Make sure to enable/uncomment the following line in devise configuration:

config.token_authentication_key = :auth_token

Upvotes: 1

18bytes
18bytes

Reputation: 6029

You need token authentication. Mobile client should have a login form and access the REST API for authentication. If authentication was successful, you will get a token which you need to send with all the subsequent requests in the same session.

http://zyphdesignco.com/blog/simple-auth-token-example-with-devise

http://matteomelani.wordpress.com/2011/10/17/authentication-for-mobile-devices/

Upvotes: 0

Related Questions