/** * Validates the input user data * * @param \Zepi\Turbo\Framework $framework * @param string $username * @return boolean|string */ protected function validateData(Framework $framework, $username) { // If the given username doesn't exists if (!$this->userManager->hasUserForUsername($username)) { return $this->translate('The inserted username does not exist.', '\\Zepi\\Web\\AccessControl'); } // Everything is okey return true; }
/** * Validates the input user data * * @param \Zepi\Turbo\Framework $framework * @param string $username * @param string $email * @param string $password * @param boolean $tos * @return boolean|string */ protected function validateData(Framework $framework, $username, $email, $password, $tos) { // If the given username already exists if ($this->userManager->hasUserForUsername($username)) { return $this->translate('The inserted username is already in use. Please select a new username.', '\\Zepi\\Web\\AccessControl'); } // Email if (!filter_var($email, FILTER_VALIDATE_EMAIL)) { return $this->translate('Please insert a valid email address.', '\\Zepi\\Web\\AccessControl'); } // Password if (strlen($password) < 8) { return $this->translate('The password needs at least 8 characters.', '\\Zepi\\Web\\AccessControl'); } // ToS if (!$tos) { return $this->translate('Please accept our terms of service.', '\\Zepi\\Web\\AccessControl'); } // Everything is okey return true; }
/** * Validates the input user data * * @param \Zepi\Turbo\Framework $framework * @param string $username * @param string $password * @return boolean|\Zepi\Web\AccessControl\Entity\User */ protected function validateUserData(Framework $framework, $username, $password) { // If the password isn't at least 8 characters long if (strlen($password) < 8) { return false; } // If the given username doesn't exists if (!$this->userManager->hasUserForUsername($username)) { return false; } $user = $this->userManager->getUserForUsername($username); // If the user not is usable if ($user === false) { return false; } // If the inserted password not is correct if (!$user->comparePasswords($password)) { return false; } // Everything is okey return $user; }
/** * Returns true if the username is in use and not is the edited user. * * @param string $username * @param \Zepi\Web\AccessControl\Entity\User $user * @return boolean */ protected function isUsernameInUse($username, User $user) { return $this->userManager->hasUserForUsername($username) && $this->userManager->getUserForUsername($username)->getUuid() != $user->getUuid(); }