function bakery_eat_gingerbread_cookie in Bakery Single Sign-On System 6.2
Same name and namespace in other branches
- 7.2 bakery.module \bakery_eat_gingerbread_cookie()
Respond with account information.
1 string reference to 'bakery_eat_gingerbread_cookie'
- bakery_menu in ./
bakery.module - Implementation of hook_menu().
File
- ./
bakery.module, line 1448
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(array(
'name' => $name,
));
if (!$account && $or_email) {
$account = user_load(array(
'mail' => $name,
));
}
if ($account) {
_bakery_save_slave_uid($account, $slave, $slave_uid);
$payload = array();
$payload['name'] = $account->name;
$payload['mail'] = $account->mail;
$payload['uid'] = $account->uid;
// For use in slave init field.
// 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);
}
else {
$message = t('No account found');
header('HTTP/1.1 409 Conflict');
}
module_invoke_all('exit');
print $message;
exit;
}