2018-02-09 03:49:49 +00:00
|
|
|
<?php
|
|
|
|
/**
|
2020-02-09 16:18:46 +01:00
|
|
|
* @copyright Copyright (C) 2020, Friendica
|
|
|
|
*
|
|
|
|
* @license GNU AGPL version 3 or any later version
|
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Affero General Public License as
|
|
|
|
* published by the Free Software Foundation, either version 3 of the
|
|
|
|
* License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU Affero General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Affero General Public License
|
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
*
|
2018-02-09 03:49:49 +00:00
|
|
|
*/
|
2018-12-26 01:06:24 -05:00
|
|
|
|
2019-12-27 22:19:28 +01:00
|
|
|
namespace Friendica\Module\Security;
|
2018-02-09 03:49:49 +00: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 22:34:11 +01:00
|
|
|
use Friendica\DI;
|
2019-06-11 19:41:11 -04:00
|
|
|
use Friendica\Model\Profile;
|
2018-02-09 03:49:49 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Logout module
|
|
|
|
*/
|
|
|
|
class Logout extends BaseModule
|
|
|
|
{
|
|
|
|
/**
|
2020-01-19 06:05:23 +00:00
|
|
|
* Process logout requests
|
2018-02-09 03:49:49 +00:00
|
|
|
*/
|
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 19:41:11 -04:00
|
|
|
$visitor_home = null;
|
|
|
|
if (remote_user()) {
|
|
|
|
$visitor_home = Profile::getMyURL();
|
2020-01-07 00:14:01 +01: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-07 00:10:15 +01:00
|
|
|
DI::cookie()->clear();
|
2020-01-07 00:14:01 +01:00
|
|
|
DI::session()->clear();
|
2019-06-11 19:41:11 -04:00
|
|
|
|
|
|
|
if ($visitor_home) {
|
|
|
|
System::externalRedirect($visitor_home);
|
|
|
|
} else {
|
2020-01-07 00:14:01 +01:00
|
|
|
info(DI::l10n()->t('Logged out.'));
|
2019-12-16 00:28:31 +01:00
|
|
|
DI::baseUrl()->redirect();
|
2019-06-11 19:41:11 -04:00
|
|
|
}
|
2018-02-09 03:49:49 +00:00
|
|
|
}
|
|
|
|
}
|