/** * Loads the number of allowed requests and the corresponding timestamp from a persistent storage. * * @param string $name name of action e.g. `FooController::actionIndex` * @return array an array of two elements. The first element is the number of allowed requests, * and the second element is the corresponding UNIX timestamp. */ public function loadAllowance($name) { if (!($allowance = $this->session->get(['_allowance', $name]))) { return [null, time()]; } return [$allowance['maxRequests'], $allowance['timestamp']]; }
/** * Returns the URL that the browser should be redirected to after successful login. * * This method reads the return URL from the session. It is usually used by the login action which * may call this method to redirect the browser to where it goes after successful authentication. * * @param string|array $defaultUrl the default return URL in case it was not set previously. * If this is null and the return URL was not set previously, {@see \rock\request\Request::getHomeUrl()} will be redirected to. * @return string the URL that the user should be redirected to after login. */ public function getReturnUrl($defaultUrl = null) { $url = $this->storage->get($this->returnUrlParam, $defaultUrl); return $url === null ? $this->request->getHomeUrl() : Url::modify($url); }