Make sure no secondary email addresses are used for registration or when changing email address

feature.better-home
Patrick Georgi 2011-02-20 21:23:27 +01:00
parent bbf9ef8b3d
commit 46fda14e08
2 changed files with 3 additions and 7 deletions

View File

@ -93,9 +93,7 @@ class IDF_Form_Register extends Pluf_Form
function clean_email()
{
$this->cleaned_data['email'] = mb_strtolower(trim($this->cleaned_data['email']));
$guser = new Pluf_User();
$sql = new Pluf_SQL('email=%s', $this->cleaned_data['email']);
if ($guser->getCount(array('filter' => $sql->gen())) > 0) {
if (Pluf::factory('IDF_EmailAddress')->get_user_for_email_address($this->cleaned_data['email']) != null) {
throw new Pluf_Form_Invalid(sprintf(__('The email "%s" is already used. If you need, click on the help link to recover your password.'), $this->cleaned_data['email']));
}
return $this->cleaned_data['email'];

View File

@ -393,10 +393,8 @@ class IDF_Form_UserAccount extends Pluf_Form
function clean_email()
{
$this->cleaned_data['email'] = mb_strtolower(trim($this->cleaned_data['email']));
$guser = new Pluf_User();
$sql = new Pluf_SQL('email=%s AND id!=%s',
array($this->cleaned_data['email'], $this->user->id));
if ($guser->getCount(array('filter' => $sql->gen())) > 0) {
$user = Pluf::factory('IDF_EmailAddress')->get_user_for_email_address($this->cleaned_data['email']);
if ($user != null and $user->id != $this->user->id) {
throw new Pluf_Form_Invalid(sprintf(__('The email "%s" is already used.'), $this->cleaned_data['email']));
}
return $this->cleaned_data['email'];