Tell me more ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

I'm trying to create a one-site mobile app using AngularJS and jquerymobile, deploying it as a "native" app using PhoneGap. The one-page navigation is build up similar to this jsfiddle, using jquerymobiles data-role="page" for in-page navigation.

<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 app should provide a login screen to the user. After a successful login the user is able to access the rest of the app.

The app is the mobile companion for a Django driven web portal. Regarding the web portal things are straight forward. I log the user in and check on the server whether the user is allowed to access a certain view.

For the mobile client I'm a bit lost. Do I have to implement some kind of tokken authentication? How can I get the csrf token into my angularjs scripts to do some ajax calls (GET and POST) to my backend? How can I refresh page-1 independent from page-2? I would look for some hints where to start and what to take care off.

share|improve this question

1 Answer

We’ve the following :

[Client {JQM}/{PhoneGap}] ← REST → [Web-Server]—[Django/Social-Auth]

When DeviceReady and JQM are fully initialized, client issues GET to the server to test if it is already authenticated.

If yes, go to starting page; otherwise, go to log-in page. Then it is just normal authentication flow. Once it is authenticated, route to starting page.

Hope this help.

We did set cors in the client

$( document ).bind( "mobileinit", function() {
    $.support.cors = true;
    $.mobile.allowCrossDomainPages = true;
}
share|improve this answer
Hi, thanks for your reply. Could you maybe some more details / source code. Quite hard to imagine how this all works together. I just found a very interesting/sophisticated approach implemented in AngularJS. frederiknakstad.com/… I'm thinking about to convert it into a PhoneGap structure.. – Tom 5 hours ago
@Tom Just took a look at the link that you provided. It is more or less the same approach that we did. Since we are using backbone.marionette and Django/Social-Auth, so the specifics are different but the overall approach is the same as what we did. – Ming Chan 3 hours ago

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.