src/Brick/User/UserManager.php
public function authenticate(array $credentials)
	{
		list($username, $password) = $credentials;

		$user = $this->repository->getActiveUser($username);

		if (!$user) {
			throw new Security\AuthenticationException('The username is incorrect.', self::IDENTITY_NOT_FOUND);

		} elseif (!Passwords::verify($password, $user->password)) {
			throw new Security\AuthenticationException('The password is incorrect.', self::INVALID_CREDENTIAL);

		} elseif (Passwords::needsRehash($user->password)) {
			$this->repository->update($user->id, ['password' => Passwords::hash($password)]);
		}

		$data = $user->toArray();
		unset($data['password']);

		return new Security\Identity($user->id, $user->role, $data);
	}
public function authenticate(array $credentials)
	{
		list($username, $password) = $credentials;

		$user = $this->repository->getActiveUser($username);

		if (!$user) {
			throw new Security\AuthenticationException('The username is incorrect.', self::IDENTITY_NOT_FOUND);

		} elseif (!Passwords::verify($password, $user->password)) {
			throw new Security\AuthenticationException('The password is incorrect.', self::INVALID_CREDENTIAL);

		} elseif (Passwords::needsRehash($user->password)) {
			$this->repository->update($user->id, ['password' => Passwords::hash($password)]);
		}

		$data = $user->toArray();
		unset($data['password']);

		return new Security\Identity($user->id, $user->role, $data);
	}
Performs an authentication

@param array $credentials

@return Security\Identity|Security\IIdentity
@throws \Nette\Security\AuthenticationException