示例#1
0
    /**
     * confirmProcess: check the given key and username
     */
    public function confirmSignup($username, $key)
    {
        // The TB WAY:
        $userId = APP_User::userId($username);
        if (!$userId) {
            return $error = 'NoSuchMember';
        }
        $keyDB = APP_User::getSetting($userId, 'regkey');
        if (!$keyDB) {
            return $error = 'NoStoredKey';
        }
        if ($keyDB->value != $key) {
            return $error = 'WrongKey';
        }
        $memberEntity = new Member();
        $member = $memberEntity->findByUsername($username);
        $query = '
SELECT members.Status AS Status
FROM members
WHERE members.id = \'' . $member->id . '\'
        ';
        $s = $this->dao->query($query);
        if ($s->numRows() != 1) {
            return $error = 'NoMember';
        }
        $Status = $s->fetch(PDB::FETCH_OBJ)->Status;
        if ($Status != 'MailToConfirm') {
            return $error = 'Status' . $Status;
        }
        APP_User::activate($userId);
        $query = "\r\nUPDATE members\r\nSET Status = 'Active'\r\nWHERE id=" . $member->id;
        // The email is confirmed > make the status Active
        $s = $this->dao->query($query);
        if (!$s) {
            // TODO: always integrate this check?
            throw new PException('Could not determine if email is in use!');
        }
        $View = new SignupView($this);
        define('DOMAIN_MESSAGE_ID', 'bewelcome.org');
        // TODO: config
        $View->sendActivationMail($member);
        return false;
        // no error
    }
示例#2
0
 /**
  * confirmation process
  *
  * @param string $handle
  * @param string $key
  * @return boolean
  */
 public function confirmRegister($handle, $key)
 {
     $userId = APP_User::userId($handle);
     if (!$userId) {
         return false;
     }
     $keyDB = APP_User::getSetting($userId, 'regkey');
     if (!$keyDB) {
         return false;
     }
     if ($keyDB->value != $key) {
         return false;
     }
     APP_User::activate($userId);
     return true;
 }