Skip to content
This repository has been archived by the owner on Mar 14, 2023. It is now read-only.

Commit

Permalink
uses Nette 3.1 features
Browse files Browse the repository at this point in the history
  • Loading branch information
dg committed Jan 5, 2021
1 parent 7da4491 commit 4b5a3a4
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 9 deletions.
2 changes: 1 addition & 1 deletion app/Bootstrap.php
Expand Up @@ -4,7 +4,7 @@

namespace App;

use Nette\Configurator;
use Nette\Bootstrap\Configurator;


class Bootstrap
Expand Down
12 changes: 5 additions & 7 deletions app/Model/UserManager.php
Expand Up @@ -11,7 +11,7 @@
/**
* Users management.
*/
final class UserManager implements Nette\Security\IAuthenticator
final class UserManager implements Nette\Security\Authenticator
{
use Nette\SmartObject;

Expand All @@ -24,12 +24,12 @@ final class UserManager implements Nette\Security\IAuthenticator
COLUMN_ROLE = 'role';


private Nette\Database\Context $database;
private Nette\Database\Explorer $database;

private Passwords $passwords;


public function __construct(Nette\Database\Context $database, Passwords $passwords)
public function __construct(Nette\Database\Explorer $database, Passwords $passwords)
{
$this->database = $database;
$this->passwords = $passwords;
Expand All @@ -40,10 +40,8 @@ public function __construct(Nette\Database\Context $database, Passwords $passwor
* Performs an authentication.
* @throws Nette\Security\AuthenticationException
*/
public function authenticate(array $credentials): Nette\Security\IIdentity
public function authenticate(string $username, string $password): Nette\Security\SimpleIdentity
{
[$username, $password] = $credentials;

$row = $this->database->table(self::TABLE_NAME)
->where(self::COLUMN_NAME, $username)
->fetch();
Expand All @@ -62,7 +60,7 @@ public function authenticate(array $credentials): Nette\Security\IIdentity

$arr = $row->toArray();
unset($arr[self::COLUMN_PASSWORD_HASH]);
return new Nette\Security\Identity($row[self::COLUMN_ID], $row[self::COLUMN_ROLE], $arr);
return new Nette\Security\SimpleIdentity($row[self::COLUMN_ID], $row[self::COLUMN_ROLE], $arr);
}


Expand Down
2 changes: 1 addition & 1 deletion app/config/common.neon
Expand Up @@ -28,4 +28,4 @@ services:
- App\Forms\FormFactory
- App\Forms\SignInFormFactory
- App\Forms\SignUpFormFactory
router: App\Router\RouterFactory::createRouter
- App\Router\RouterFactory::createRouter

0 comments on commit 4b5a3a4

Please sign in to comment.