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) { 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']; }
/** * Validate the key. */ public function clean_key() { $this->cleaned_data['key'] = trim($this->cleaned_data['key']); $error = __('We are sorry but this confirmation key is not valid. Maybe you should directly copy/paste it from your confirmation email.'); if (false === ($email_id = self::checkKeyHash($this->cleaned_data['key']))) { throw new Pluf_Form_Invalid($error); } $guser = new Pluf_User(); $sql = new Pluf_SQL('email=%s AND id=%s', $email_id); if ($guser->getCount(array('filter' => $sql->gen())) != 1) { throw new Pluf_Form_Invalid($error); } return $this->cleaned_data['key']; }
/** * Validate the key. */ public function clean_key() { $this->cleaned_data['key'] = trim($this->cleaned_data['key']); $error = __('We are sorry but this validation key is not valid. Maybe you should directly copy/paste it from your validation email.'); if (false === ($cres = IDF_Form_PasswordInputKey::checkKeyHash($this->cleaned_data['key']))) { throw new Pluf_Form_Invalid($error); } $guser = new Pluf_User(); $sql = new Pluf_SQL('email=%s AND id=%s', array($cres[0], $cres[1])); if ($guser->getCount(array('filter' => $sql->gen())) != 1) { throw new Pluf_Form_Invalid($error); } if (time() - $cres[2] > 86400) { throw new Pluf_Form_Invalid(__('Sorry, but this verification key has expired, please restart the password recovery sequence. For security reasons, the verification key is only valid 24h.')); } return $this->cleaned_data['key']; }
public function clean_login() { $this->cleaned_data['login'] = mb_strtolower(trim($this->cleaned_data['login'])); if (preg_match('/[^a-z0-9]/', $this->cleaned_data['login'])) { throw new Pluf_Form_Invalid(sprintf(__('The login "%s" can only contain letters and digits.'), $this->cleaned_data['login'])); } $guser = new Pluf_User(); $sql = new Pluf_SQL('login=%s', $this->cleaned_data['login']); if ($guser->getCount(array('filter' => $sql->gen())) > 0) { throw new Pluf_Form_Invalid(sprintf(__('The login "%s" is already used, please find another one.'), $this->cleaned_data['login'])); } return $this->cleaned_data['login']; }
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) { throw new Pluf_Form_Invalid(sprintf(__('The email "%s" is already used.'), $this->cleaned_data['email'])); } return $this->cleaned_data['email']; }