Open ghost opened 7 years ago
@tazimhossain I don't know. I hear there is a "cookie domain" setting that can go in settings.php to allow the cookie to be placed on another domain, I've never tried it though, so I'm not entirely certain on its capabilities.
Thanx for reply. I am already doing that, but dont know why its not working for authentication. :(
I've had this problem trying to run various requests from an app on a sub-domain.
After a lot of debugging I've managed to get it working but it requires the 'withCredentials' flag adding to the request.
I've attached a patch with adds a new setting to the jDrupal object, its a non-breaking change so it can be merged without affecting any existing installations.
To use this functionality you just need to set the config:
jDrupal.config('withCredentials', true);
On the server side, I have the following headers set:
header("Access-Control-Allow-Origin: [subdomain]"); header("Access-Control-Allow-Methods: GET, POST, PUT, DELETE, OPTIONS"); header('Access-Control-Allow-Credentials: true'); header('Access-Control-Allow-Headers: Content-Type'); withCredentials.patch.zip
Thank you @adam-clarey , any chance you'd like to turn this into a Pull Request?
Ive since realised its not necessary, you can just use the hook_rest_pre_process:
// When initialising your app
function init() {
jDrupal.modules['cordova'] = ['cordova_rest_pre_process', 'cordova_rest_post_process'];
}
/**
* Implements hook_rest_pre_process()
* @param xhr
* @param data
*/
window.cordova_rest_pre_process = function(xhr, data) {
// Required for sharing cookies across domains.
xhr.withCredentials = true;
}
When i collect node data from example.com site, its collect data into sub.example.com. but, when i trying to get current user information, its not working, its return anonymous.
How can i solve authentication with jdrupal, any suggestion?