web\User loginRequired()

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 true. When this is true and the request does not accept HTML responses the current URL will not be SET as the return URL. Also instead of redirecting the user an ForbiddenHttpException is thrown. This parameter is available since version 2.0.8.

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.

doc_Yii
2016-10-30 17:17:24
Comments
Leave a Comment

Please login to continue.