@ -45,7 +45,7 @@ function upei_roblib_ill_add_request($form_state, $aid) {
if(!isset($aid) || is_array($aid)) {
if(!isset($aid) || is_array($aid)) {
upei_roblib_ill_log_request($relais_arr, $aid);
upei_roblib_ill_log_request($relais_arr, $aid);
drupal_set_message(t('Error retrieving authentication token, @message', array('@message' => $aid['Problem']['Message'])), 'error');
drupal_set_message(t('Error retrieving authentication token, @message', array('@message' => $aid['Problem']['Message'])), 'error');
return array('ConfirmMessage' => $aid['Problem']['Message'] . ' You may have entered an incorrect Campus ID' );
return array('ConfirmMessage' => t('There was an error processing your request, @msg', array('@msg' => $aid['Problem']['Message'])) );
}
}
$result = drupal_http_request($url . '?aid=' . $aid, $options);
$result = drupal_http_request($url . '?aid=' . $aid, $options);
module_load_include('inc', 'upei_roblib_ill', 'includes/db');
module_load_include('inc', 'upei_roblib_ill', 'includes/db');
@ -65,7 +65,7 @@ function upei_roblib_ill_add_request($form_state, $aid) {
* @return string/array
* @return string/array
* Returns a Relais authentication id (token) or an array containing the Relais response error which should include the error message if authentication fails
* Returns a Relais authentication id (token) or an array containing the Relais response error which should include the error message if authentication fails
*/
*/
function upei_roblib_ill_authenticate($barcode) {
function upei_roblib_ill_authenticate($barcode, $surname ) {
$url = variable_get('upei_roblib_ill_auth_url', 'https://caul-cbua.relais-host.com/portal-service/user/authentication');
$url = variable_get('upei_roblib_ill_auth_url', 'https://caul-cbua.relais-host.com/portal-service/user/authentication');
$json_arr = array();
$json_arr = array();
$json_arr['ApiKey'] = variable_get('upei_roblib_ill_relais_key');
$json_arr['ApiKey'] = variable_get('upei_roblib_ill_relais_key');
@ -80,14 +80,20 @@ function upei_roblib_ill_authenticate($barcode) {
'headers' => array('Content-Type' => 'application/json'),
'headers' => array('Content-Type' => 'application/json'),
);
);
$result = drupal_http_request($url, $options);
$result = drupal_http_request($url, $options);
if($result->code != '200') {
$response_data['Problem']['Message'] = $result->error;
return $response_data;
}
$response_data = json_decode($result->data, TRUE);
$response_data = json_decode($result->data, TRUE);
if ($result->code == '200') {
if ($result->code == '200') {
if (isset($response_data['Problem'])) {
if (isset($response_data['Problem']) || $response_data['LastName'] !== $surname) {
$err_message = isset($response_data['Problem']['Message']) ? $response_data['Problem']['Message'] : '';
$err_message .= t( ' Your Campus ID could be incorrect or your Last Name does not match what is stored in the profile for the user with the specified Campus ID');
$response_data['Problem']['Message'] = $err_message;
return $response_data;
return $response_data;
}
}
$aid = $response_data['AuthorizationId'];
$aid = $response_data['AuthorizationId'];
}
}
return isset($aid) ? $aid : $response_data;
return isset($aid) ? $aid : $response_data;
}
}