Vyhození hlášky když uživatel není aktivovaný

Upozornění: Tohle vlákno je hodně staré a informace nemusí být platné pro současné Nette.
motorcb
Člen | 552
+
0
-

Zdravím.
Řeším přihlašování uživatelů. Aby se uživatel mohl přihlásit, musí být aktivovaný.

Authenticator.php:

public function authenticate(array $credentials)
{
	list($username, $password) = $credentials;

	$row = $this->users->where('nick', $username)->fetch();
	if (!$row) {
		throw new NS\AuthenticationException("User '$username' not found.", self::IDENTITY_NOT_FOUND);
	}

	$row = $this->users->where( array( 'nick' => $username, 'activate' => 1 ) )->fetch();
	if (!$row) {
		throw new NS\AuthenticationException("User '$username' is'n active.", self::IDENTITY_NOT_FOUND);
	}

	if ($row->password !== $this->calculateHash($password)) {
		throw new NS\AuthenticationException("Invalid password.", self::INVALID_CREDENTIAL);
	}

  $this->users->where('nick', $username)->update( $row );
	unset($row->password);
	return new NS\Identity($row->id, $row->role, $row->toArray());
}

LoginForm.php

    public function signInFormSubmitted(Form $form)
    {
        try {
            $user = $this->presenter->getUser();
            $values = $form->getValues();
            if ($values->persistent) {
                $user->setExpiration('+3 hours', FALSE);
            }
            $user->login($values->nick, $values->password);
            $this->presenter->redirect('Homepage:default');
        } catch (NS\AuthenticationException $e) {
            $this->flashMessage($e, 'error');
        }
    }

Když vypisuji : $this->flashMessage($e, ‚error‘); Je mi vrácena hodně dlouhá chybová hláška. Mě by stačilo při vyjímce vypsat jen text u vyjímky ( throw new NS\AuthenticationException(„User ‚$username‘ not found.“, self::IDENTITY_NOT_FOUND); ⇒ „User ‚$username‘ not found.“)

Nevěděl by někdo jak to?
Díky za rady a nakopnutí

22
Člen | 1478
+
0
-
$e->getMessage();

Doporučil bych ti základy OOP nastudovat a podívat se na http://php.net, tam jsou taky zajímavé věci.

Tohle forum slouží opravdu k něčemu jinému.

MartinitCZ
Člen | 580
+
0
-
$this->flashMessage($e, 'error');

replace with:

$this->flashMessage("User '" . $values->nick . "' not found.", 'error');