-
-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added UserStorage, successor for IUserStorage
- Loading branch information
Showing
6 changed files
with
145 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
<?php | ||
|
||
/** | ||
* This file is part of the Nette Framework (https://nette.org) | ||
* Copyright (c) 2004 David Grudl (https://davidgrudl.com) | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Nette\Security; | ||
|
||
|
||
/** | ||
* Interface for persistent storage for user object data. | ||
*/ | ||
interface UserStorage | ||
{ | ||
/** Log-out reason */ | ||
public const | ||
LOGOUT_MANUAL = 1, | ||
LOGOUT_INACTIVITY = 2; | ||
|
||
/** | ||
* Sets the authenticated state of user. | ||
*/ | ||
function saveAuthentication(IIdentity $identity): void; | ||
|
||
/** | ||
* Removed authenticated state of user. | ||
*/ | ||
function clearAuthentication(bool $clearIdentity): void; | ||
|
||
/** | ||
* Returns user authenticated state, identity and logout reason. | ||
* @return array{bool, ?IIdentity, ?int} | ||
*/ | ||
function getState(): array; | ||
|
||
/** | ||
* Enables log out from the persistent storage after inactivity (like '20 minutes'). | ||
*/ | ||
function setExpiration(?string $expire, bool $clearIdentity): void; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
class MockUserStorage implements Nette\Security\IUserStorage | ||
{ | ||
private $auth = false; | ||
|
||
private $identity; | ||
|
||
|
||
public function setAuthenticated(bool $state) | ||
{ | ||
$this->auth = $state; | ||
} | ||
|
||
|
||
public function isAuthenticated(): bool | ||
{ | ||
return $this->auth; | ||
} | ||
|
||
|
||
public function setIdentity(Nette\Security\IIdentity $identity = null) | ||
{ | ||
$this->identity = $identity; | ||
} | ||
|
||
|
||
public function getIdentity(): ?Nette\Security\IIdentity | ||
{ | ||
return $this->identity; | ||
} | ||
|
||
|
||
public function setExpiration(?string $time, int $flags = 0) | ||
{ | ||
} | ||
|
||
|
||
public function getLogoutReason(): ?int | ||
{ | ||
return null; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters