function bakery_eat_gingerbread_cookie in Bakery Single Sign-On System 7.2
Same name and namespace in other branches
- 6.2 bakery.module \bakery_eat_gingerbread_cookie()
Respond with account information.
1 string reference to 'bakery_eat_gingerbread_cookie'
- bakery_menu in ./
bakery.module - Implements hook_menu().
File
- ./
bakery.module, line 1560 - Module file for the Bakery.
Code
function bakery_eat_gingerbread_cookie() {
// Session was set in validate.
$name = $_SESSION['bakery']['name'];
unset($_SESSION['bakery']['name']);
$or_email = $_SESSION['bakery']['or_email'];
unset($_SESSION['bakery']['or_email']);
$slave = $_SESSION['bakery']['slave'];
unset($_SESSION['bakery']['slave']);
$slave_uid = $_SESSION['bakery']['uid'];
unset($_SESSION['bakery']['uid']);
$key = variable_get('bakery_key', '');
$account = user_load_by_name($name);
if (!$account && $or_email) {
$account = user_load_by_mail($name);
}
if ($account) {
_bakery_save_slave_uid($account, $slave, $slave_uid);
$payload = array();
$payload['name'] = $account->name;
$payload['mail'] = $account->mail;
// For use in slave init field.
$payload['uid'] = $account->uid;
// Add any synced fields.
foreach (variable_get('bakery_supported_fields', array(
'mail' => 'mail',
'name' => 'name',
)) as $type => $enabled) {
if ($enabled && $account->{$type}) {
$payload[$type] = $account->{$type};
}
}
// Invoke implementations of hook_bakery_transmit() for syncing arbitrary
// data.
$payload['data'] = module_invoke_all('bakery_transmit', NULL, $account);
$payload['timestamp'] = $_SERVER['REQUEST_TIME'];
// Respond with encrypted and signed account information.
$message = bakery_bake_data($payload);
drupal_add_http_header('Content-Type', 'application/octet-stream; type=bakery-baked-data');
}
else {
$message = t('No account found');
header('HTTP/1.1 409 Conflict');
}
module_invoke_all('exit');
print $message;
exit;
}