Friday, April 4, 2014

Redirect to json extension

In our continued head long plunge into iOS app integration we have now got the iOS app talking nicely with the Cake controller code using json, Router::parseExtensions(); and json views. The next challenge is redirecting.

For example, the Auth component's loginRedirect is set to a non json view (e.g. /users/profile) as that is where the web site expects to go after a successful login. When the login comes from the iOS app (via /users/login.json) I really need it to redirect to the json equivalent (e.g. /users/profile.json) else the iOS receives the fully rendered HTML (which is bad).

What's the recommended way of dealing with this? Hard coding json specific redirects, or is there something clever available within the RequestHandler component that can detect that the current action is a json action and any redirect should also be to a json action?

--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.

No comments: