friendica/src/Module/Security/Logout.php

44 lines
803 B
PHP
Raw Normal View History

<?php
/**
* @file src/Module/Logout.php
*/
namespace Friendica\Module\Security;
use Friendica\BaseModule;
use Friendica\Core\Hook;
use Friendica\Core\System;
use Friendica\DI;
use Friendica\Model\Profile;
/**
* Logout module
*
* @author Hypolite Petovan <hypolite@mrpetovan.com>
*/
class Logout extends BaseModule
{
/**
2020-01-19 01:05:23 -05:00
* Process logout requests
*/
public static function init(array $parameters = [])
{
$visitor_home = null;
if (remote_user()) {
$visitor_home = Profile::getMyURL();
2020-01-06 18:14:01 -05:00
DI::cache()->delete('zrlInit:' . $visitor_home);
}
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();
if ($visitor_home) {
System::externalRedirect($visitor_home);
} else {
2020-01-06 18:14:01 -05:00
info(DI::l10n()->t('Logged out.'));
DI::baseUrl()->redirect();
}
}
}