-
-
Notifications
You must be signed in to change notification settings - Fork 158
/
ModuleLogout.php
88 lines (71 loc) · 2.04 KB
/
ModuleLogout.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
<?php
/*
* This file is part of Contao.
*
* (c) Leo Feyer
*
* @license LGPL-3.0-or-later
*/
namespace Contao;
use League\Uri\Components\Query;
use League\Uri\Http;
use Patchwork\Utf8;
@trigger_error('Using the logout module has been deprecated and will no longer work in Contao 5.0. Use the logout page instead.', E_USER_DEPRECATED);
/**
* Front end module "logout".
*
* @author Leo Feyer <https://github.com/leofeyer>
*
* @deprecated Deprecated since Contao 4.2, to be removed in Contao 5.0.
* Use the logout page instead.
*/
class ModuleLogout extends Module
{
/**
* Template
* @var string
*/
protected $strTemplate;
/**
* Logout the current user and redirect
*
* @return string
*/
public function generate()
{
if (TL_MODE == 'BE')
{
$objTemplate = new BackendTemplate('be_wildcard');
$objTemplate->wildcard = '### ' . Utf8::strtoupper($GLOBALS['TL_LANG']['FMD']['logout'][0]) . ' ###';
$objTemplate->title = $this->headline;
$objTemplate->id = $this->id;
$objTemplate->link = $this->name;
$objTemplate->href = 'contao/main.php?do=themes&table=tl_module&act=edit&id=' . $this->id;
return $objTemplate->parse();
}
$strLogoutUrl = System::getContainer()->get('security.logout_url_generator')->getLogoutUrl();
$strRedirect = Environment::get('base');
// Redirect to last page visited
if ($this->redirectBack && ($strReferer = $this->getReferer()))
{
$strRedirect = $strReferer;
}
// Redirect to jumpTo page
elseif (($objTarget = $this->objModel->getRelated('jumpTo')) instanceof PageModel)
{
/** @var PageModel $objTarget */
$strRedirect = $objTarget->getAbsoluteUrl();
}
$uri = Http::createFromString($strLogoutUrl);
// Add the redirect= parameter to the logout URL
$query = new Query($uri->getQuery());
$query = $query->merge('redirect=' . $strRedirect);
$this->redirect((string) $uri->withQuery((string) $query));
return '';
}
/**
* Generate the module
*/
protected function compile() {}
}
class_alias(ModuleLogout::class, 'ModuleLogout');