Skip to content

Commit

Permalink
User: source of constants for logout reasons
Browse files Browse the repository at this point in the history
  • Loading branch information
dg committed Dec 11, 2023
1 parent 6b525ac commit 7033de1
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 13 deletions.
2 changes: 1 addition & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ $user->setExpiration(null);

Expiration must be set to value equal or lower than the expiration of sessions.

The reason of the last logout can be obtained by method `$user->getLogoutReason()`, which returns either the constant `Nette\Security\IUserStorage::INACTIVITY` if the time expired or `IUserStorage::MANUAL` when the `logout()` method was called.
The reason of the last logout can be obtained by method `$user->getLogoutReason()`, which returns either the constant `Nette\Security\User::LogoutInactivity` if the time expired or `User::LogoutManual` when the `logout()` method was called.

In presenters, you can verify login in the `startup()` method:

Expand Down
12 changes: 6 additions & 6 deletions src/Security/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,15 @@ class User
{
use Nette\SmartObject;

/** @deprecated */
/** Log-out reason */
public const
MANUAL = IUserStorage::MANUAL,
INACTIVITY = IUserStorage::INACTIVITY;
LogoutManual = 1,
LogoutInactivity = 2;

/** Log-out reason */
/** @deprecated */
public const
LogoutManual = UserStorage::LogoutManual,
LogoutInactivity = UserStorage::LogoutInactivity;
MANUAL = self::LogoutManual,
INACTIVITY = self::LogoutInactivity;

public const LOGOUT_MANUAL = self::LogoutManual;
public const LOGOUT_INACTIVITY = self::LogoutInactivity;
Expand Down
10 changes: 4 additions & 6 deletions src/Security/UserStorage.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,11 @@
*/
interface UserStorage
{
/** Log-out reason */
public const
LogoutManual = 1,
LogoutInactivity = 2;
/** @deprecated use User::LogoutManual */
public const LOGOUT_MANUAL = 1;

public const LOGOUT_MANUAL = self::LogoutManual;
public const LOGOUT_INACTIVITY = self::LogoutInactivity;
/** @deprecated use User::LogoutInactivity */
public const LOGOUT_INACTIVITY = 2;

/**
* Sets the authenticated state of user.
Expand Down

0 comments on commit 7033de1

Please sign in to comment.