I am new in titanium alloy development project, we already have an android app which was built on titanium template. I would like change this to alloy template. My current issue is I need to make a user authentication. In our default app we use the following code
var xhr=Titanium.Network.createHTTPClient();
xhr.onerror = function(e){
Ti.API.error('Bad Sever =>'+e.error);
};
xhr.open("POST","http://xxxxxxxxx.com/api/login/");//ADD your URL
xhr.setRequestHeader("Set-Cookie", "application/json");
var param={ "username":$.email.value,"password":$.password.value,"api":true,"type":'P' };
Ti.API.info('Params'+JSON.stringify(param));
xhr.send(param);
Can I do same method in alloy app as well? Or have any other good methods? If I use the same method I will get JSON response from API. Once logged in I would like to switch to new window.
Here I am using the code below to create new window.
var newwindow = Alloy.createController('threadShow');
newwindow.getView().open();
Is it right method? Or do have any other methods? How can I check whether user is authenticated or not in all controller? Or do we have any method like session as in web development project?