I have a web application built using jQuery Mobile and PHP (Framework CodeIgniter). Now I am also trying to make a version of PhoneGap to make it available as a standalone application. However, the PHP web application. version uses Ion Auth, the CodeIgniter plugin for authentication. Therefore, when you go to a page that requires authentication, the application redirects you to the login method of the authentication controller. And after authentication, it redirects you back to the home page (in this case, on the jQuery Mobile page). This works great in a web application. Since the home page is in any case opened by the home controller.
But here's the bottom line: in the PhoneGap version, the home page should be the index.html file in PhoneGap. Obviously, you can load a different URL at startup by adding a value to PhoneGap.plist, but this is not acceptable for Apple to send to the app store. And if I do a redirect in authentication, I cannot return to the index.html file after authentication ...
So, how do you bypass authentication in the PhoneGap / jQuery mobile app?
UPDATE:
I tried this according to one of the answers, but the application is still trying to go to the account / login page (which does not exist) when I just want to login through the message and return the value from the method:
$('#login_form').bind('submit', function () {
event.preventDefault();
$.post('http://localhost/app_xcode/account/login', $(this).serialize(), function (response) {
var response = response;
if (response == true) {
$.mobile.changePage('#toc', "slide");
} else {
alert('login failed');
$.mobile.changePage('#toc', "slide");
}
});
});
Here's the controller method:
function login()
{
$this->form_validation->set_rules('identity', 'Identity', 'required');
$this->form_validation->set_rules('password', 'Password', 'required');
$base_url = $this->config->item('base_url');
$mobile = $this->detect_mobile();
if ($mobile === false && $base_url != 'http://localhost/app_xcode/')
redirect('account/notAMobile');
else if ($this->form_validation->run() == true) {
$remember = (bool)$this->input->post('remember');
if ($this->ion_auth->login($this->input->post('identity'), $this->input->post('password'), $remember)) {
$this->session->set_flashdata('message', $this->ion_auth->messages());
echo true;
}
else
{
$this->session->set_flashdata('message', $this->ion_auth->errors());
}
}
else
{
$this->data['message'] = (validation_errors()) ? validation_errors()
: $this->session->flashdata('message');
$this->data['identity'] = array('name' => 'identity',
'id' => 'identity',
'type' => 'text',
'value' => $this->form_validation->set_value('identity'),
);
$this->data['password'] = array('name' => 'password',
'id' => 'password',
'type' => 'password',
);
}
}
, , . , ? , jQuery Mobile , URL?