public function leave($sender, $param)
{
$application = $this->getApplication();
if ($application->getResponse()->getStatusCode() === 401) {
$service = $application->getService();
if ($service instanceof TPageService) {
$returnUrl = $application->getRequest()->getRequestUri();
$this->setReturnUrl($returnUrl);
$url = $service->constructUrl($this->getLoginPage());
$application->getResponse()->redirect($url);
}
}
}