Validates the input user data

@param \Zepi\Turbo\Framework $framework
@param string $username
@return boolean|string
488574
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;
    }
1338689
public function login(string $username, string $password)
    {
        $this->userInfo = $this->makeRequest('POST', 'login', compact('username', 'password'));

        if (!isset($this->userInfo['error']) && isset($this->userInfo['data']['id'])) {
            return true;
        }

        return false;
    }
804899
public function validate_user($username_or_email = '', $password = '')
	{
		$username_or_email = trim($username_or_email) ?: trim(\Input::post(\Config::get('simpleauth.username_post_key', 'username')));
		$password = trim($password) ?: trim(\Input::post(\Config::get('simpleauth.password_post_key', 'password')));

		if (empty($username_or_email) or empty($password))
		{
			return false;
		}

		$password = $this->hash_password($password);
		$user = \DB::select_array(\Config::get('simpleauth.table_columns', array('*')))
			->where_open()
			->where('username', '=', $username_or_email)
			->or_where('email', '=', $username_or_email)
			->where_close()
			->where('password', '=', $password)
			->from(\Config::get('simpleauth.table_name'))
			->execute(\Config::get('simpleauth.db_connection'))->current();

		return $user ?: false;
	}
56772
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;
    }
1280726
public function ValidateUniqueFields($Username, $Email, $UserID = '', $Return = FALSE) {
      $Valid = TRUE;
      $Where = array();
      if (is_numeric($UserID))
         $Where['UserID <> '] = $UserID;
      
      $Result = array('Name' => TRUE, 'Email' => TRUE);

      // Make sure the username & email aren't already being used
      if (C('Garden.Registration.NameUnique', TRUE) && $Username) {
         $Where['Name'] = $Username;
         $TestData = $this->GetWhere($Where);
         if ($TestData->NumRows() > 0) {
            $Result['Name'] = FALSE;
            $Valid = FALSE;
         }
         unset($Where['Name']);
      }
      
      if (C('Garden.Registration.EmailUnique', TRUE) && $Email) {
         $Where['Email'] = $Email;
         $TestData = $this->GetWhere($Where);
         if ($TestData->NumRows() > 0) {
            $Result['Email'] = FALSE;
            $Valid = FALSE;
         }
      }
      
      if ($Return) {
         return $Result;
      } else {
         if (!$Result['Name'])
            $this->Validation->AddValidationResult('Name', 'The name you entered is already in use by another member.');
         if (!$Result['Email'])
            $this->Validation->AddValidationResult('Email', 'The email you entered is in use by another member.');
         return $Valid;
      }
   }
140054
public function delete($username)
    {
        $parameters['username'] = $username;
        return $this->apiClient->callEndpoint(
            'user',
            $parameters,
            null,
            HttpMethod::REQUEST_DELETE
        );
    }
1190852
public function authentication($username, $password)
    {
        $endpoint = sprintf('authentication?username=%s', urlencode($username));
        $parameters['value'] = $password;
        return $this->apiClient->callEndpoint(
            $endpoint,
            $parameters,
            null,
            HttpMethod::REQUEST_POST
        );
    }
1301839
public function validate(Framework $framework)
    {
        $translationManager = $framework->getInstance('\\Zepi\\Core\\Language\\Manager\\TranslationManager');
        
        if ($this->minValue !== null && $this->value < $this->minValue) {
            return new Error(
                Error::INVALID_VALUE,
                $translationManager->translate(
                    'The value for the field %field% is lower than the allowed minimum (%min%).', 
                    '\\Zepi\\Web\\UserInterface', 
                    array(
                        'field' => $this->label,
                        'min' => $this->minValue
                    )
                )
            );
        }
        
        if ($this->maxValue !== null && $this->value > $this->maxValue) {
            return new Error(
                Error::INVALID_VALUE,
                $translationManager->translate(
                    'The value for the field %field% is higher than the allowed maximum (%max%).', 
                    '\\Zepi\\Web\\UserInterface', 
                    array(
                        'field' => $this->label,
                        'max' => $this->maxValue
                    )
                )
            );
        }
        
        return true;
    }
915631
public function validatePasswordNotUseUsername($username, $password) {
        $washedPassword = trim($password);
        $washedPassword = strtolower($password);

        $washedUsername = trim($username);
        $washedUsername = strtolower($username);

        if ($washedPassword == $washedUsername) {
            return false;
        }

        // remove hyphens in the username, and compare again
        // maybe username "Bob Bloom" has password "bob-bloom"
        $washedUsernameHyphen = str_replace(" ", "-", $washedUsername);
        if ($washedPassword == $washedUsernameHyphen) {
            return false;
        }

        // remove underscores in the username, and compare again
        // maybe username "Bob Bloom" has password "bob_bloom"
        $washedUsernameUnderscore = str_replace(" ", "_", $washedUsername);
        if ($washedPassword == $washedUsernameUnderscore) {
            return false;
        }

        // remove spaces in the username, and compare again
        // maybe username "Bob Bloom" has password "bobbloom"
        $washedUsername = str_replace(" ", "", $washedUsername);
        if ($washedPassword == $washedUsername) {
            return false;
        }

        return true;
    }
1286928
public function block($username) {
		// Make sure we're logged in and have a valid access token.
		if (!$this->auth_token || !$this->username) {
			return FALSE;
		}

		$timestamp = parent::timestamp();
		$result = parent::post(
			'/friend',
			array(
				'action' => 'block',
				'friend' => $username,
				'timestamp' => $timestamp,
				'username' => $this->username,
			),
			array(
				$this->auth_token,
				$timestamp,
			)
		);

		return !empty($result->message);
	}
564501
public function setUsername($username = null)
    {
        if ($username === null && ($model = $this->getUsername()->one())) {
            return $model->delete() > 0;
        }
        if ($username instanceof Username) {
            $username = $username->content;
        }
        $model = $this->createUsername($username);
        return $model->save();
    }
404406
public function checkUserCredentials($username, $password)
    {
        $this->user = $this->app['auth']->getUserWithCredentials($username, $password);

        return $this->user instanceof User;
    }
1167448
public function authenticate($userName, $password)
    {
        $this->beforeLogin($userName, $password);
        $result = $this->adapter->authenticate($userName, $password);
        if ($result) {
            $this->profile->loadProfile("$this->userNameFieldName = '$userName'");
            $this->profile->resetToken();
        }
        $this->afterLogin($userName, $password, $result);
        return $result;
    }
1176263
public function validateUserName($userName)
    {
        if (empty($userName)) {
            $this->addError('userName', 'User name cannot be empty');
            return false;
        }

        if (!is_string($userName)) {
            $this->addError('userName', 'User name must be a string');
            return false;
        }

        if (mb_strlen($userName, 'UTF-8') > 255) {
            $this->addError('userName', 'User name length has to be less or equal to 255');
            return false;
        }


        return true;
    }
436678
public function validationUserName(Validator $validator) {
		$validator->setProvider('userTable', $this->_table);

		$validator->add($this->_field('username'), [
			'notBlank' => [
				'rule' => 'notBlank',
				'message' => __d('user_tools', 'An username is required.')
			],
			'length' => [
				'rule' => ['lengthBetween', 3, 32],
				'message' => __d('user_tools', 'The username must be between 3 and 32 characters.')
			],
			'unique' => [
				'rule' => ['validateUnique', ['scope' => 'username']],
				'provider' => 'userTable',
				'message' => __d('user_tools', 'The username is already in use.')
			],
			'alphaNumeric' => [
				'rule' => 'alphaNumeric',
				'message' => __d('user_tools', 'The username must be alpha numeric.')
			]
		]);

		return $validator;
	}
123093
public function generateDeviceValidationToken($username)
    {
        $this->username = $username;
        $validationToken = $this->crypt()->generateRandomString(6, '0123456789');

        $devices = $this->getMeta()->allowedDevices;

        $devices[] = [
            'device'          => $this->getDeviceFingerprint(),
            'created'         => 0,
            'token'           => '',
            'validationToken' => $validationToken,
            'confirmed'       => false
        ];

        $this->getMeta()->allowedDevices = $devices;
        $this->getMeta()->save();

        return $validationToken;
    }
560474
public function isValidUser($userName, $password)
    {
        $filter = new IteratorFilter();
        $passwordGenerator = $this->getUserDefinition()->getClosureForUpdate('password');
        $filter->addRelation($this->getUserDefinition()->loginField(), Relation::EQUAL, strtolower($userName));
        $filter->addRelation(
            $this->getUserDefinition()->getPassword(),
            Relation::EQUAL,
            $passwordGenerator($password, null)
        );
        return $this->getUser($filter);
    }