2018-02-09 03:49:49 +00:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* @file src/Module/Logout.php
|
|
|
|
*/
|
2018-12-26 06:06:24 +00:00
|
|
|
|
2019-12-27 21:19:28 +00:00
|
|
|
namespace Friendica\Module\Security;
|
2018-02-09 03:49:49 +00:00
|
|
|
|
|
|
|
use Friendica\BaseModule;
|
2019-09-29 06:26:02 +00:00
|
|
|
use Friendica\Core\Cache;
|
2018-12-26 06:06:24 +00:00
|
|
|
use Friendica\Core\Hook;
|
2018-02-09 03:49:49 +00:00
|
|
|
use Friendica\Core\L10n;
|
2019-12-03 21:29:37 +00:00
|
|
|
use Friendica\Core\Session;
|
2019-06-11 23:41:11 +00:00
|
|
|
use Friendica\Core\System;
|
2019-12-15 21:34:11 +00:00
|
|
|
use Friendica\DI;
|
2019-06-11 23:41:11 +00:00
|
|
|
use Friendica\Model\Profile;
|
2018-02-09 03:49:49 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Logout module
|
|
|
|
*
|
2018-09-15 23:28:38 +00:00
|
|
|
* @author Hypolite Petovan <hypolite@mrpetovan.com>
|
2018-02-09 03:49:49 +00:00
|
|
|
*/
|
|
|
|
class Logout extends BaseModule
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* @brief Process logout requests
|
|
|
|
*/
|
2019-11-05 21:48:54 +00:00
|
|
|
public static function init(array $parameters = [])
|
2018-02-09 03:49:49 +00:00
|
|
|
{
|
2019-06-11 23:41:11 +00:00
|
|
|
$visitor_home = null;
|
|
|
|
if (remote_user()) {
|
|
|
|
$visitor_home = Profile::getMyURL();
|
2019-09-29 06:26:02 +00:00
|
|
|
Cache::delete('zrlInit:' . $visitor_home);
|
2019-06-11 23:41:11 +00:00
|
|
|
}
|
|
|
|
|
2018-12-26 06:06:24 +00:00
|
|
|
Hook::callAll("logging_out");
|
2020-01-06 23:10:15 +00:00
|
|
|
DI::cookie()->clear();
|
2019-12-11 19:30:31 +00:00
|
|
|
Session::clear();
|
2019-06-11 23:41:11 +00:00
|
|
|
|
|
|
|
if ($visitor_home) {
|
|
|
|
System::externalRedirect($visitor_home);
|
|
|
|
} else {
|
|
|
|
info(L10n::t('Logged out.'));
|
2019-12-15 23:28:31 +00:00
|
|
|
DI::baseUrl()->redirect();
|
2019-06-11 23:41:11 +00:00
|
|
|
}
|
2018-02-09 03:49:49 +00:00
|
|
|
}
|
|
|
|
}
|