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