How to implement authentication for Django mobile client based on JqueryMobile, AngularJs, PhoneGap

I am trying to create a one-site mobile application using AngularJS and jquerymobile, deploying it as a β€œnative” application using PhoneGap . One-page navigation is created similarly to jsfiddle , using jquerymobiles data-role="page" to navigate pages.

 <div id="page-1" data-role="page">..some content for page one</div> <div id="page-2" data-role="page">..some content for page two</div> 

The application should provide the user with a login screen. After a successful login, the user can access the rest of the application.

The app is a mobile companion for the web portal managed by Django. As for the web portal, everything goes straight. I register the user and check on the server whether the user is allowed access to a specific view.

For a mobile client, I'm a little lost. Do I need to do some token authentication? How can I get the csrf token in my angularjs scripts to make some ajax calls (GET and POST) for my backend? How can I update page-1 regardless of page-2 ? I would like to find some tips on where to start and what to take care of.

+4
source share
1 answer

We have the following:

[Client {JQM} / {PhoneGap}] ← DEPARTMENT β†’ [Web Server] - [Django / Social-Auth ]

When DeviceReady and JQM are fully initialized, the client issues a GET to the server for verification if it has already been authenticated.

If yes, go to the start page; otherwise go to the login page. Then this is a normal authentication flow. After authentication, go to the start page.

I hope for this help.

We installed cors in the client

 $( document ).bind( "mobileinit", function() { $.support.cors = true; $.mobile.allowCrossDomainPages = true; } 
+2
source

Source: https://habr.com/ru/post/1487299/


All Articles