Friday, 15 August 2014

iOS, rails, devise: How to persist user login (session vs authentication_token) -



iOS, rails, devise: How to persist user login (session vs authentication_token) -

i trying build ios app rails backend. have chosen devise user authentication , session management system.

currently have modified original devise registrationscontroller , sessionscontroller homecoming json response. sample create method in sessionscontroller follows:

def create build_resource if resource.save if resource.active_for_authentication? sign_up(resource_name, resource) respond_to |format| format.json { render :json => ["success", resource, user.serialize_into_cookie(resource)]} end else expire_session_data_after_sign_in! respond_to |format| format.json { render :json => ["inactive", resource]} end end else clean_up_passwords resource respond_to |format| format.json { render :json => ["error", resource]} end end end

what wondering best way persist login through ios app is.

most of devise tutorials web applications , not sure how should apply these ios app.

the framework using 'afnetworking', , class using networking 'afhttpclient' , 'afjsonrequestoperation'. don't know how retrieve , store session on client side can utilize later.

maybe should utilize different framework networking uses proper headers , things retrieve session , cookie? asihttpclient?

or should utilize token_authenticatable feature in devise persist login?

if project json backend, preferred utilize token_authenticatable. json easy , clean work , devise lets set , handles you.

ios ruby-on-rails devise

No comments:

Post a Comment