Revize 793a2c68
Přidáno uživatelem Filip Jani před více než 5 roky(ů)
- ID 793a2c687f1328578258d5697ca7c92bd89edf95
- Rodič 6b983650
app/model/Authenticator.php | ||
---|---|---|
1 | 1 |
<?php |
2 | 2 |
|
3 |
namespace Model; |
|
3 |
namespace App\Model;
|
|
4 | 4 |
|
5 |
use Model\Repository\UserRepository; |
|
6 |
use Model\Repository\UserRoleRepository; |
|
5 |
use App\Model\Repository\UserRepository;
|
|
6 |
use App\Model\Repository\UserRoleRepository;
|
|
7 | 7 |
use Nette\Security\AuthenticationException; |
8 | 8 |
use Nette\Security\IAuthenticator; |
9 | 9 |
use Nette\Security\Identity; |
... | ... | |
32 | 32 |
*/ |
33 | 33 |
function authenticate(array $credentials) |
34 | 34 |
{ |
35 |
list($username, $password) = $credentials;
|
|
35 |
list($login, $password) = $credentials;
|
|
36 | 36 |
|
37 |
$row = $this->userRepository->findByUsername($username);
|
|
37 |
$row = $this->userRepository->findByLogin($login);
|
|
38 | 38 |
if(!$row){ |
39 | 39 |
throw new AuthenticationException('Uživatel nebyl nalezen.'); |
40 | 40 |
} |
... | ... | |
49 | 49 |
$roles = $row->related(UserRoleRepository::TABLE_NAME, UserRoleRepository::COLUMN_USER_ID) |
50 | 50 |
->fetchField(UserRoleRepository::COLUMN_ROLE_ID); |
51 | 51 |
|
52 |
return new Identity($row->{UserRepository::COLUMN_ID}, $roles);
|
|
52 |
return new UserIdentity($row->{UserRepository::COLUMN_ID}, $row->{UserRepository::COLUMN_USERNAME}, $roles);
|
|
53 | 53 |
} |
54 | 54 |
} |
Také k dispozici: Unified diff
7216 přidání přihlašování uživatelů a úprava namespace pro repository