IOS, rails, devise: how to save custom login (session vs authentication_token)
I am trying to create an iOS app with a backend. I have selected the device as the user authentication and session management system.
I have currently modified the original Devise RegistrationsController and SessionController to return a JSON response. The sample creation method in the SessionController looks like this:
def create
build_resource
if resource.save
if resource.active_for_authentication?
sign_up(resource_name, resource)
respond_to do |format|
format.json { render :json => ["success", resource, User.serialize_into_cookie(resource)]}
end
else
expire_session_data_after_sign_in!
respond_to do |format|
format.json { render :json => ["inactive", resource]}
end
end
else
clean_up_passwords resource
respond_to do |format|
format.json { render :json => ["error", resource]}
end
end
end
What I'm wondering is the best way to keep the login through the iOS app.
Most of the tutorials are for web apps only and I'm not sure how to apply them in my iOS app.
I am using the "AFNetworking" framework and the class I am using for networking are "AFHTTPClient" and "AFJSONRequestOperation". But I don't know how to retrieve and store the client-side session so that I can use it later.
-
Maybe I should be using a different framework for networks that uses the correct headers and things to fetch session and cookies? something like ASIHTTPClient?
-
Or should I use the token_authenticatable function in development to proceed with the registration?
source to share