Esempio n. 1
0
 /**
  * confirm user account via code sent in email
  * @param int $userId
  * @param string $code
  * @return bool
  */
 public function confirm($userId, $code)
 {
     $vcode = new VerificationCode($this->db, $this->logger);
     if (!$vcode->getByUserId($userId)) {
         return array(false, self::ERROR_VERIFICATION_ERROR);
     }
     if ($vcode->code != $code) {
         return array(false, self::ERROR_VERIFICATION_ERROR);
     }
     $user = new User($this->db, $this->logger);
     if ($user->getById($userId)) {
         $user->status = User::STATUS_ENABLED;
         $user->save();
     }
     return array(true, 0);
 }