1: <?php
2:
3: /**
4: * This file is part of the Nette Framework (https://nette.org)
5: * Copyright (c) 2004 David Grudl (https://davidgrudl.com)
6: */
7:
8: namespace Nette\Security;
9:
10:
11: /**
12: * Interface for persistent storage for user object data.
13: */
14: interface IUserStorage
15: {
16: /** Log-out reason {@link IUserStorage::getLogoutReason()} */
17: const
18: MANUAL = 0b0001,
19: INACTIVITY = 0b0010;
20:
21: /** Log-out behavior */
22: const CLEAR_IDENTITY = 0b1000;
23:
24: /** @deprecated */
25: const BROWSER_CLOSED = 0b0100;
26:
27: /**
28: * Sets the authenticated status of this user.
29: * @param bool
30: * @return static
31: */
32: function setAuthenticated($state);
33:
34: /**
35: * Is this user authenticated?
36: * @return bool
37: */
38: function isAuthenticated();
39:
40: /**
41: * Sets the user identity.
42: * @return static
43: */
44: function setIdentity(IIdentity $identity = null);
45:
46: /**
47: * Returns current user identity, if any.
48: * @return IIdentity|null
49: */
50: function getIdentity();
51:
52: /**
53: * Enables log out from the persistent storage after inactivity.
54: * @param string|int|\DateTimeInterface number of seconds or timestamp
55: * @param int flag IUserStorage::CLEAR_IDENTITY
56: * @return static
57: */
58: function setExpiration($time, $flags = 0);
59:
60: /**
61: * Why was user logged out?
62: * @return int|null
63: */
64: function getLogoutReason();
65: }
66: