- if(x($_SESSION,'register')) {
- 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=' . notags(trim($v));
- if($k === 'contact/email')
- $args .= '&email=' . 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=' . $nick;
- elseif($first)
- $args .= '&nickname=' . $first;
+ $authid = $_REQUEST['openid_identity'];
+
+ if(! strlen($authid)) {
+ logger(L10n::t('OpenID protocol error. No ID returned.') . EOL);
+ goaway(System::baseUrl());
+ }
+
+ // NOTE: we search both for normalised and non-normalised form of $authid
+ // because the normalization step was removed from setting
+ // mod/settings.php in 8367cad so it might have left mixed
+ // records in the user table
+ //
+ $r = q("SELECT *
+ FROM `user`
+ WHERE ( `openid` = '%s' OR `openid` = '%s' )
+ AND `blocked` = 0 AND `account_expired` = 0
+ AND `account_removed` = 0 AND `verified` = 1
+ LIMIT 1",
+ DBA::escape($authid), DBA::escape(normalise_openid($authid))
+ );