I already have CRUD web application which is build using Codeigniter PHP framework and Ion Auth authentication library (for Codeigniter). So users needs to log-in to use the site etc.
Now Im building small mobile app using Phonegap & jQuery mobile which uses this same backend. There is "REST like" api in backend which handles all ajax requests from mobile client.
How should I handle user authentication for this mobile app? I want to use as much as possible existing backend codebase.
Im planning something like this:
How to do this in backend side? For login, I can use Codeigniter Ion Auth library login methods and get Codeigniter (PHP) session id. In second request when user send some actual data together with sessoin id, how to validate the session id? Or is it better idea to build completely new login functionality for mobile app authentication than try to use existing functionality (Codeignitre Ion Auth library)?
All ideas and suggestions are more than welcome!
I think the best solution is just to put a middleware between your controllers and the request.
You can do that with the Hooks : http://ellislab.com/codeigniter/user-guide/general/hooks.html
Use the pre controller hook.
For managing easily API requests, play with the HTTP code
You have all the codes here : http://en.wikipedia.org/wiki/List_of_HTTP_status_codes
Avoid to use a complex library when you can do it easier. The hooks is the best for me.
I use NodeJS and the concept is the same with Express middlewares.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With