Hi friends,
I'm trying to log in Bonita with PHP calling the loginservice API.
I have an html page with the controls, then when in the page press "Log in", I call the php function to call de API with the user credentials.
Then I return something like this to the html page:
Json: HTTP/1.1 302 Found Server: Apache-Coyote/1.1 Set-Cookie: bonita.tenant=1 Set-Cookie: JSESSIONID=0DEDDD983C605AA11EF2E605F8B4F3E7; Path=/bonita; HttpOnly Set-Cookie: X-Bonita-API-Token=d9a7835c-717e-40a3-b50e-9110c073ae08; Path=/ Location: portal/homepage Content-Length: 0 Date: Thu, 28 Feb 2019 20:07:52 GMT
The next what I want, is to redirect to the home portal page with the user logged, but before that. What I have to do?
This is my php code:
<?php
// get the q parameter from URL
$user = $_REQUEST["username"];
$pass = $_REQUEST["password"];
$hint = "";
$data = array("username"=> $user,
"password"=> $pass,
"redirect"=> "true");
$payload = http_build_query($data);
// Prepare new cURL resource
$ch = curl_init('http://localhost:8080/bonita/loginservice');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLINFO_HEADER_OUT, true);
curl_setopt($ch, CURLOPT_HEADER, true);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $payload);
// Submit the POST request
$result = curl_exec($ch);
$info = curl_getinfo($ch);
// Close cURL session handle
curl_close($ch);
// Output "no suggestion" if no hint was found or output correct values
echo $result;
?>
Thanks for all the help.