show error when openid is already registered

This commit is contained in:
Christian Weiske 2012-02-15 10:30:45 +01:00
parent 09cf21aa7e
commit 90ba326f85
2 changed files with 13 additions and 5 deletions

View File

@ -39,7 +39,7 @@
<p>
<form method="post" action="<?php echo $formaction; ?>">
<label for="openid"><?php echo T_('New OpenID'); ?></label>
<label for="openid"><?php echo T_('New E-Mail or OpenID'); ?></label>
<input type="text" id="openid" name="openid_identifier" size="20" />
<button type="submit" name="action" value="registerOpenId">
<?php echo T_('Register'); ?>

View File

@ -260,10 +260,21 @@ class SemanticScuttle_Service_OpenId extends SemanticScuttle_DbService
* @param string $identifier OpenID identifier (URL)
* @param string $email OpenID-delivered e-mail address of the user
*
* @return boolean True if it worked, false if not
* @return void
*
* @throws SemanticScuttle_Exception When something goes wrong,
* e.g. the OpenID is already registered
*/
public function register($uId, $identifier, $email = null)
{
if ($this->getId($identifier) !== null) {
//already registered
throw new SemanticScuttle_Exception_User(
'OpenID already registered: ' . $identifier,
21
);
}
//FIXME: use email when google-openid
$query = 'INSERT INTO ' . $this->getTableName()
. ' ' . $this->db->sql_build_array(
@ -277,10 +288,7 @@ class SemanticScuttle_Service_OpenId extends SemanticScuttle_DbService
GENERAL_ERROR, 'Could not register OpenID',
'', __LINE__, __FILE__, $query, $this->db
);
return false;
}
return true;
}
/**