- header('X-Account-Management-Status: active; name="' . $a->user['username'] . '"; id="' . $a->user['nickname'] .'"');
- if(($a->module !== 'home') && isset($_SESSION['return_url']))
- goaway($a->get_baseurl() . '/' . $_SESSION['return_url']);
- else
- goaway($a->get_baseurl());
+ // Successful OpenID login - but we can't match it to an existing account.
+ // New registration?
+
+ if (intval(Config::get('config', 'register_policy')) === REGISTER_CLOSED) {
+ notice(L10n::t('Account not found and OpenID registration is not permitted on this site.') . EOL);
+ goaway(System::baseUrl());
+ }
+
+ unset($_SESSION['register']);
+ $args = '';
+ $attr = $openid->getAttributes();
+ if (is_array($attr) && count($attr)) {
+ foreach ($attr as $k => $v) {
+ if ($k === 'namePerson/friendly') {
+ $nick = notags(trim($v));
+ }
+ if($k === 'namePerson/first') {
+ $first = notags(trim($v));
+ }
+ if($k === 'namePerson') {
+ $args .= '&username=' . urlencode(notags(trim($v)));
+ }
+ if ($k === 'contact/email') {
+ $args .= '&email=' . urlencode(notags(trim($v)));
+ }
+ if ($k === 'media/image/aspect11') {
+ $photosq = bin2hex(trim($v));
+ }
+ if ($k === 'media/image/default') {
+ $photo = bin2hex(trim($v));
+ }
+ }
+ }
+ if ($nick) {
+ $args .= '&nickname=' . urlencode($nick);
+ }
+ elseif ($first) {
+ $args .= '&nickname=' . urlencode($first);
+ }
+
+ if ($photosq) {
+ $args .= '&photo=' . urlencode($photosq);
+ }
+ elseif ($photo) {
+ $args .= '&photo=' . urlencode($photo);
+ }
+
+ $args .= '&openid_url=' . urlencode(notags(trim($authid)));
+
+ goaway(System::baseUrl() . '/register?' . $args);
+
+ // NOTREACHED