diff --git a/.travis.yml b/.travis.yml
index e5bdfacd..29a67b31 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -2,6 +2,7 @@ language: php
php:
- 5.6
- 7.0
+ - 7.1
matrix:
include:
diff --git a/composer.json b/composer.json
index cf2a1b65..20cc5c02 100644
--- a/composer.json
+++ b/composer.json
@@ -18,10 +18,10 @@
"nette/utils": "~2.4"
},
"require-dev": {
- "nette/di": "~2.3",
- "nette/http": "~2.3",
+ "nette/di": "~2.4",
+ "nette/http": "~2.4",
"nette/tester": "~2.0",
- "tracy/tracy": "^2.3"
+ "tracy/tracy": "^2.4"
},
"conflict": {
"nette/nette": "<2.2"
diff --git a/readme.md b/readme.md
index 17e2c204..a7fb6944 100644
--- a/readme.md
+++ b/readme.md
@@ -42,23 +42,20 @@ Simple, right?
.[note]
Logging in requires users to have cookies enabled - other methods are not safe!
-Besides logging the user out with the `logout()` method, it can be done automatically based on specified time interval or closing the browser window. For this configuration we have to call `setExpiration()` during the login process. As an argument, it takes a relative time in seconds, UNIX timestamp, or textual representation of time. The second argument specifies whether the user should be logged out when the browser is closed.
+Besides logging the user out with the `logout()` method, it can be done automatically based on specified time interval or closing the browser window. For this configuration we have to call `setExpiration()` during the login process. As an argument, it takes a relative time in seconds, UNIX timestamp, or textual representation of time.
```php
-// login expires after 30 minutes of inactivity or after closing browser
-$user->setExpiration('30 minutes', TRUE);
+// login expires after 30 minutes of inactivity
+$user->setExpiration('30 minutes');
// login expires after two days of inactivity
-$user->setExpiration('2 days', FALSE);
-
-// login expires when a browser is closed, but not sooner (ie. without a time limit)
-$user->setExpiration(0, TRUE);
+$user->setExpiration('2 days');
```
.[note]
Expiration must be set to value equal or lower than the expiration of [sessions].
-The reason of last logout can be obtained by method `$user->getLogoutReason()`, which returns one of these constants: `IUserStorage::INACTIVITY` if time expired, `IUserStorage::BROWSER_CLOSED` when user has closed the browser or `IUserStorage::MANUAL` when the `logout()` method was called.
+The reason of last logout can be obtained by method `$user->getLogoutReason()`, which returns one of these constants: `IUserStorage::INACTIVITY` if time expired or `IUserStorage::MANUAL` when the `logout()` method was called.
To make the example above work, we in fact have to create an object that verifies user's name and password. It's called **authenticator**. Its trivial implementation is the class [api:Nette\Security\SimpleAuthenticator], which in its constructor accepts an associative array:
diff --git a/src/Bridges/SecurityTracy/templates/UserPanel.panel.phtml b/src/Bridges/SecurityTracy/templates/UserPanel.panel.phtml
index c18dfeaa..fdc801d0 100644
--- a/src/Bridges/SecurityTracy/templates/UserPanel.panel.phtml
+++ b/src/Bridges/SecurityTracy/templates/UserPanel.panel.phtml
@@ -2,8 +2,7 @@
namespace Nette\Bridges\SecurityTracy;
-use Nette,
- Tracy\Dumper;
+use Tracy\Dumper;
?>
diff --git a/src/Bridges/SecurityTracy/templates/UserPanel.tab.phtml b/src/Bridges/SecurityTracy/templates/UserPanel.tab.phtml
index ec658b48..2b41f20c 100644
--- a/src/Bridges/SecurityTracy/templates/UserPanel.tab.phtml
+++ b/src/Bridges/SecurityTracy/templates/UserPanel.tab.phtml
@@ -2,8 +2,6 @@
namespace Nette\Bridges\SecurityTracy;
-use Nette;
-
?>
diff --git a/src/Security/IUserStorage.php b/src/Security/IUserStorage.php
index 27f5ab5d..938c6047 100644
--- a/src/Security/IUserStorage.php
+++ b/src/Security/IUserStorage.php
@@ -14,13 +14,16 @@
interface IUserStorage
{
/** Log-out reason {@link IUserStorage::getLogoutReason()} */
- const MANUAL = 0b0001,
- INACTIVITY = 0b0010,
- BROWSER_CLOSED = 0b0100;
+ const
+ MANUAL = 0b0001,
+ INACTIVITY = 0b0010;
/** Log-out behavior */
const CLEAR_IDENTITY = 0b1000;
+ /** @deprecated */
+ const BROWSER_CLOSED = 0b0100;
+
/**
* Sets the authenticated status of this user.
* @param bool
@@ -49,7 +52,7 @@ function getIdentity();
/**
* Enables log out from the persistent storage after inactivity.
* @param string|int|\DateTimeInterface number of seconds or timestamp
- * @param int Log out when the browser is closed | Clear the identity from persistent storage?
+ * @param int Clear the identity from persistent storage?
* @return void
*/
function setExpiration($time, $flags = 0);
diff --git a/src/Security/Identity.php b/src/Security/Identity.php
index 2a896c74..039563eb 100644
--- a/src/Security/Identity.php
+++ b/src/Security/Identity.php
@@ -51,7 +51,7 @@ public function __construct($id, $roles = NULL, $data = NULL)
/**
* Sets the ID of user.
* @param mixed
- * @return self
+ * @return static
*/
public function setId($id)
{
@@ -73,7 +73,7 @@ public function getId()
/**
* Sets a list of roles that the user is a member of.
* @param array
- * @return self
+ * @return static
*/
public function setRoles(array $roles)
{
diff --git a/src/Security/Permission.php b/src/Security/Permission.php
index 6e243ccb..964be77e 100644
--- a/src/Security/Permission.php
+++ b/src/Security/Permission.php
@@ -56,7 +56,7 @@ class Permission implements IAuthorizator
* @param string|array
* @throws Nette\InvalidArgumentException
* @throws Nette\InvalidStateException
- * @return self
+ * @return static
*/
public function addRole($role, $parents = NULL)
{
@@ -175,7 +175,7 @@ public function roleInheritsFrom($role, $inherit, $onlyParents = FALSE)
*
* @param string
* @throws Nette\InvalidStateException
- * @return self
+ * @return static
*/
public function removeRole($role)
{
@@ -214,7 +214,7 @@ public function removeRole($role)
/**
* Removes all Roles from the list.
*
- * @return self
+ * @return static
*/
public function removeAllRoles()
{
@@ -244,7 +244,7 @@ public function removeAllRoles()
* @param string
* @throws Nette\InvalidArgumentException
* @throws Nette\InvalidStateException
- * @return self
+ * @return static
*/
public function addResource($resource, $parent = NULL)
{
@@ -351,7 +351,7 @@ public function resourceInheritsFrom($resource, $inherit, $onlyParent = FALSE)
*
* @param string
* @throws Nette\InvalidStateException
- * @return self
+ * @return static
*/
public function removeResource($resource)
{
@@ -383,7 +383,7 @@ public function removeResource($resource)
/**
* Removes all Resources.
- * @return self
+ * @return static
*/
public function removeAllResources()
{
@@ -411,7 +411,7 @@ public function removeAllResources()
* @param string|array|Permission::ALL resources
* @param string|array|Permission::ALL privileges
* @param callable assertion
- * @return self
+ * @return static
*/
public function allow($roles = self::ALL, $resources = self::ALL, $privileges = self::ALL, $assertion = NULL)
{
@@ -428,7 +428,7 @@ public function allow($roles = self::ALL, $resources = self::ALL, $privileges =
* @param string|array|Permission::ALL resources
* @param string|array|Permission::ALL privileges
* @param callable assertion
- * @return self
+ * @return static
*/
public function deny($roles = self::ALL, $resources = self::ALL, $privileges = self::ALL, $assertion = NULL)
{
@@ -443,7 +443,7 @@ public function deny($roles = self::ALL, $resources = self::ALL, $privileges = s
* @param string|array|Permission::ALL roles
* @param string|array|Permission::ALL resources
* @param string|array|Permission::ALL privileges
- * @return self
+ * @return static
*/
public function removeAllow($roles = self::ALL, $resources = self::ALL, $privileges = self::ALL)
{
@@ -458,7 +458,7 @@ public function removeAllow($roles = self::ALL, $resources = self::ALL, $privile
* @param string|array|Permission::ALL roles
* @param string|array|Permission::ALL resources
* @param string|array|Permission::ALL privileges
- * @return self
+ * @return static
*/
public function removeDeny($roles = self::ALL, $resources = self::ALL, $privileges = self::ALL)
{
@@ -476,7 +476,7 @@ public function removeDeny($roles = self::ALL, $resources = self::ALL, $privileg
* @param string|array|Permission::ALL privileges
* @param callable assertion
* @throws Nette\InvalidStateException
- * @return self
+ * @return static
*/
protected function setRule($toAdd, $type, $roles, $resources, $privileges, $assertion = NULL)
{
diff --git a/src/Security/User.php b/src/Security/User.php
index 5872a0bb..79136d64 100644
--- a/src/Security/User.php
+++ b/src/Security/User.php
@@ -26,9 +26,12 @@ class User
use Nette\SmartObject;
/** @deprecated */
- const MANUAL = IUserStorage::MANUAL,
- INACTIVITY = IUserStorage::INACTIVITY,
- BROWSER_CLOSED = IUserStorage::BROWSER_CLOSED;
+ const
+ MANUAL = IUserStorage::MANUAL,
+ INACTIVITY = IUserStorage::INACTIVITY;
+
+ /** @deprecated */
+ const BROWSER_CLOSED = IUserStorage::BROWSER_CLOSED;
/** @var string default role for unauthenticated user */
public $guestRole = 'guest';
@@ -141,7 +144,7 @@ public function getId()
/**
* Sets authentication handler.
- * @return self
+ * @return static
*/
public function setAuthenticator(IAuthenticator $handler)
{
@@ -166,14 +169,14 @@ public function getAuthenticator($need = TRUE)
/**
* Enables log out after inactivity.
* @param string|int|\DateTimeInterface number of seconds or timestamp
- * @param bool log out when the browser is closed?
- * @param bool clear the identity from persistent storage?
- * @return self
+ * @param int|bool flag IUserStorage::CLEAR_IDENTITY
+ * @param bool clear the identity from persistent storage? (deprecated)
+ * @return static
*/
- public function setExpiration($time, $whenBrowserIsClosed = TRUE, $clearIdentity = FALSE)
+ public function setExpiration($time, $flags = NULL, $clearIdentity = FALSE)
{
- $flags = ($whenBrowserIsClosed ? IUserStorage::BROWSER_CLOSED : 0) | ($clearIdentity ? IUserStorage::CLEAR_IDENTITY : 0);
- $this->storage->setExpiration($time, $flags);
+ $clearIdentity = $clearIdentity || $flags === IUserStorage::CLEAR_IDENTITY;
+ $this->storage->setExpiration($time, $clearIdentity ? IUserStorage::CLEAR_IDENTITY : 0);
return $this;
}
@@ -238,7 +241,7 @@ public function isAllowed($resource = IAuthorizator::ALL, $privilege = IAuthoriz
/**
* Sets authorization handler.
- * @return self
+ * @return static
*/
public function setAuthorizator(IAuthorizator $handler)
{