Example #1
0
 /**
  * Make sure email address is valid
  * Make sure email is not already used by some
  * user
  *
  * @return object $this
  */
 protected function validateEmail()
 {
     $email = strtolower($this->getSubmittedValue('email'));
     if (false === Validate::email($email)) {
         $this->setError('email', 'This is not a valid email address');
     }
     $a = $this->Registry->Mongo->EMAILS->findOne(array('email' => $email));
     if (!empty($a)) {
         $this->setError('email', 'There is already an account with this email address. Have you already registered on our site before?');
     }
     return $this;
 }
Example #2
0
    /**
     * @todo
     * Check that this email does not already exist
     *
     * @throws \Lampcms\FormException
     * @return object $this
     */
    protected function validateEmail()
    {
        $email = \mb_strtolower($this->Request['email']);
        if (false === Validate::email($email)) {
            throw new \Lampcms\FormException('@@Email address@@ ' . $this->Request['email'] . ' @@is invalid@@<br/>@@Please correct it and resubmit the form@@', 'email');
        }
        $ret = $this->Registry->Mongo->EMAILS->findOne(array('email' => $email));
        /**
         * @todo when we have 'join existing account'
         *       form at the bottom then we can also suggest that user
         *       enters username/password to join this "twitter" account
         *       with an existing account
         */
        if (!empty($ret)) {
            throw new \Lampcms\FormException('<p>Someone else (probably you) is already registered with this email address
			<p/><p>If you forgot you password, <br/>please use the <a href="{_WEB_ROOT_}/{_remindpwd_}/">This link</a> to request a new password<br/>
			or use different email address to register a new account</p>', 'email');
        }
        /**
         * Important to set $this->email
         * it is used in parent class to createEmailRecord()
         * as well as to email out the new registration password
         */
        $this->email = $email;
        return $this;
    }