loginRequired() public method
Redirects the user browser to the login page.
Before the redirection, the current URL (if it's not an AJAX url) will be kept as $returnUrl so that the user browser may be redirected back to the current page after successful login.
Make sure you set $loginUrl so that the user browser can be redirected to the specified login URL after calling this method.
Note that when $loginUrl is set, calling this method will NOT terminate the application execution.
See also \yii\web\checkAcceptHeader.
public yii\web\Response loginRequired ( $checkAjax = true, $checkAcceptHeader = true ) | ||
---|---|---|
$checkAjax | boolean |
Whether to check if the request is an AJAX request. When this is true and the request is an AJAX request, the current URL (for AJAX request) will NOT be set as the return URL. |
$checkAcceptHeader | boolean |
Whether to check if the request accepts HTML responses. Defaults to |
return | yii\web\Response |
The redirection response if $loginUrl is set |
throws | yii\web\ForbiddenHttpException |
the "Access Denied" HTTP exception if $loginUrl is not set or a redirect is not applicable. |
Please login to continue.