mirror of
https://github.com/friendica/friendica
synced 2025-04-19 05:50:10 +00:00
Split goaway to System::externalRedirectTo() and App->internalRedirect()
This commit is contained in:
parent
2ef81108b3
commit
d00ddc01af
61 changed files with 286 additions and 266 deletions
|
@ -4,6 +4,7 @@ namespace Friendica\Module;
|
|||
|
||||
use Friendica\BaseModule;
|
||||
use Friendica\Network\Probe;
|
||||
use Friendica\Core\System;
|
||||
|
||||
/**
|
||||
* Redirects to another URL based on the parameter 'addr'
|
||||
|
@ -18,7 +19,7 @@ class Acctlink extends BaseModule
|
|||
$url = defaults(Probe::uri(trim($addr)), 'url', false);
|
||||
|
||||
if ($url) {
|
||||
self::getApp()->redirect($url);
|
||||
System::externalRedirect($url);
|
||||
exit();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -66,9 +66,9 @@ class Contact extends BaseModule
|
|||
if (DBA::isResult($contact)) {
|
||||
if ($contact['self']) {
|
||||
if (($a->argc == 3) && intval($a->argv[1]) && in_array($a->argv[2], ['posts', 'conversations'])) {
|
||||
$a->redirect('profile/' . $contact['nick']);
|
||||
$a->internalRedirect('profile/' . $contact['nick']);
|
||||
} else {
|
||||
$a->redirect('profile/' . $contact['nick'] . '?tab=profile');
|
||||
$a->internalRedirect('profile/' . $contact['nick'] . '?tab=profile');
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -168,7 +168,7 @@ class Contact extends BaseModule
|
|||
info(L10n::tt('%d contact edited.', '%d contacts edited.', $count_actions));
|
||||
}
|
||||
|
||||
$a->redirect('contact');
|
||||
$a->internalRedirect('contact');
|
||||
}
|
||||
|
||||
public static function post()
|
||||
|
@ -191,7 +191,7 @@ class Contact extends BaseModule
|
|||
|
||||
if (!DBA::exists('contact', ['id' => $contact_id, 'uid' => local_user()])) {
|
||||
notice(L10n::t('Could not access contact record.') . EOL);
|
||||
$a->redirect('contact');
|
||||
$a->internalRedirect('contact');
|
||||
return; // NOTREACHED
|
||||
}
|
||||
|
||||
|
@ -374,19 +374,19 @@ class Contact extends BaseModule
|
|||
$orig_record = DBA::selectFirst('contact', [], ['id' => $contact_id, 'uid' => [0, local_user()], 'self' => false]);
|
||||
if (!DBA::isResult($orig_record)) {
|
||||
notice(L10n::t('Could not access contact record.') . EOL);
|
||||
$a->redirect('contact');
|
||||
$a->internalRedirect('contact');
|
||||
return; // NOTREACHED
|
||||
}
|
||||
|
||||
if ($cmd === 'update' && ($orig_record['uid'] != 0)) {
|
||||
self::updateContactFromPoll($contact_id);
|
||||
$a->redirect('contact/' . $contact_id);
|
||||
$a->internalRedirect('contact/' . $contact_id);
|
||||
// NOTREACHED
|
||||
}
|
||||
|
||||
if ($cmd === 'updateprofile' && ($orig_record['uid'] != 0)) {
|
||||
self::updateContactFromProbe($contact_id);
|
||||
$a->redirect('crepair/' . $contact_id);
|
||||
$a->internalRedirect('crepair/' . $contact_id);
|
||||
// NOTREACHED
|
||||
}
|
||||
|
||||
|
@ -396,7 +396,7 @@ class Contact extends BaseModule
|
|||
$blocked = Model\Contact::isBlockedByUser($contact_id, local_user());
|
||||
info(($blocked ? L10n::t('Contact has been blocked') : L10n::t('Contact has been unblocked')) . EOL);
|
||||
|
||||
$a->redirect('contact/' . $contact_id);
|
||||
$a->internalRedirect('contact/' . $contact_id);
|
||||
return; // NOTREACHED
|
||||
}
|
||||
|
||||
|
@ -406,7 +406,7 @@ class Contact extends BaseModule
|
|||
$ignored = Model\Contact::isIgnoredByUser($contact_id, local_user());
|
||||
info(($ignored ? L10n::t('Contact has been ignored') : L10n::t('Contact has been unignored')) . EOL);
|
||||
|
||||
$a->redirect('contact/' . $contact_id);
|
||||
$a->internalRedirect('contact/' . $contact_id);
|
||||
return; // NOTREACHED
|
||||
}
|
||||
|
||||
|
@ -417,7 +417,7 @@ class Contact extends BaseModule
|
|||
info((($archived) ? L10n::t('Contact has been archived') : L10n::t('Contact has been unarchived')) . EOL);
|
||||
}
|
||||
|
||||
$a->redirect('contact/' . $contact_id);
|
||||
$a->internalRedirect('contact/' . $contact_id);
|
||||
return; // NOTREACHED
|
||||
}
|
||||
|
||||
|
@ -451,13 +451,13 @@ class Contact extends BaseModule
|
|||
}
|
||||
// Now check how the user responded to the confirmation query
|
||||
if (!empty($_REQUEST['canceled'])) {
|
||||
$a->redirect('contact');
|
||||
$a->internalRedirect('contact');
|
||||
}
|
||||
|
||||
self::dropContact($orig_record);
|
||||
info(L10n::t('Contact has been removed.') . EOL);
|
||||
|
||||
$a->redirect('contact');
|
||||
$a->internalRedirect('contact');
|
||||
return; // NOTREACHED
|
||||
}
|
||||
if ($cmd === 'posts') {
|
||||
|
|
|
@ -40,7 +40,7 @@ class Login extends BaseModule
|
|||
}
|
||||
|
||||
if (local_user()) {
|
||||
$a->redirect();
|
||||
$a->internalRedirect();
|
||||
}
|
||||
|
||||
return self::form($_SESSION['return_url'], intval(Config::get('config', 'register_policy')) !== REGISTER_CLOSED);
|
||||
|
@ -89,19 +89,18 @@ class Login extends BaseModule
|
|||
// if it's an email address or doesn't resolve to a URL, fail.
|
||||
if ($noid || strpos($openid_url, '@') || !Network::isUrlValid($openid_url)) {
|
||||
notice(L10n::t('Login failed.') . EOL);
|
||||
$a->redirect();
|
||||
$a->internalRedirect();
|
||||
// NOTREACHED
|
||||
}
|
||||
|
||||
// Otherwise it's probably an openid.
|
||||
try {
|
||||
$a = get_app();
|
||||
$openid = new LightOpenID($a->getHostName());
|
||||
$openid->identity = $openid_url;
|
||||
$_SESSION['openid'] = $openid_url;
|
||||
$_SESSION['remember'] = $remember;
|
||||
$openid->returnUrl = self::getApp()->getBaseURL(true) . '/openid';
|
||||
$a->redirect($openid->authUrl());
|
||||
$openid->returnUrl = $a->getBaseURL(true) . '/openid';
|
||||
System::externalRedirect($openid->authUrl());
|
||||
} catch (Exception $e) {
|
||||
notice(L10n::t('We encountered a problem while logging in with the OpenID you provided. Please check the correct spelling of the ID.') . '<br /><br >' . L10n::t('The error message was:') . ' ' . $e->getMessage());
|
||||
}
|
||||
|
@ -149,7 +148,7 @@ class Login extends BaseModule
|
|||
} catch (Exception $e) {
|
||||
logger('authenticate: failed login attempt: ' . notags($username) . ' from IP ' . $_SERVER['REMOTE_ADDR']);
|
||||
info('Login failed. Please check your credentials.' . EOL);
|
||||
$a->redirect();
|
||||
$a->internalRedirect();
|
||||
}
|
||||
|
||||
if (!$remember) {
|
||||
|
@ -168,7 +167,7 @@ class Login extends BaseModule
|
|||
$return_url = '';
|
||||
}
|
||||
|
||||
$a->redirect($return_url);
|
||||
$a->internalRedirect($return_url);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -198,7 +197,7 @@ class Login extends BaseModule
|
|||
if ($data->hash != Authentication::getCookieHashForUser($user)) {
|
||||
logger("Hash for user " . $data->uid . " doesn't fit.");
|
||||
Authentication::deleteSession();
|
||||
$a->redirect();
|
||||
$a->internalRedirect();
|
||||
}
|
||||
|
||||
// Renew the cookie
|
||||
|
@ -235,7 +234,7 @@ class Login extends BaseModule
|
|||
logger('Session address changed. Paranoid setting in effect, blocking session. ' .
|
||||
$_SESSION['addr'] . ' != ' . $_SERVER['REMOTE_ADDR']);
|
||||
Authentication::deleteSession();
|
||||
$a->redirect();
|
||||
$a->internalRedirect();
|
||||
}
|
||||
|
||||
$user = DBA::selectFirst('user', [],
|
||||
|
@ -249,7 +248,7 @@ class Login extends BaseModule
|
|||
);
|
||||
if (!DBA::isResult($user)) {
|
||||
Authentication::deleteSession();
|
||||
$a->redirect();
|
||||
$a->internalRedirect();
|
||||
}
|
||||
|
||||
// Make sure to refresh the last login time for the user if the user
|
||||
|
|
|
@ -27,6 +27,6 @@ class Logout extends BaseModule
|
|||
Addon::callHooks("logging_out");
|
||||
Authentication::deleteSession();
|
||||
info(L10n::t('Logged out.') . EOL);
|
||||
self::getApp()->redirect();
|
||||
self::getApp()->internalRedirect();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -42,7 +42,7 @@ class Magic extends BaseModule
|
|||
|
||||
if (!$cid) {
|
||||
logger('No contact record found: ' . print_r($_REQUEST, true), LOGGER_DEBUG);
|
||||
$a->redirect($dest);
|
||||
$a->internalRedirect($dest);
|
||||
}
|
||||
|
||||
$contact = DBA::selectFirst('contact', ['id', 'nurl', 'url'], ['id' => $cid]);
|
||||
|
@ -56,7 +56,7 @@ class Magic extends BaseModule
|
|||
}
|
||||
|
||||
logger('Contact is already authenticated', LOGGER_DEBUG);
|
||||
$a->redirect($dest);
|
||||
$a->internalRedirect($dest);
|
||||
}
|
||||
|
||||
if (local_user()) {
|
||||
|
@ -100,10 +100,10 @@ class Magic extends BaseModule
|
|||
$x = strpbrk($dest, '?&');
|
||||
$args = (($x) ? '&owt=' . $token : '?f=&owt=' . $token);
|
||||
|
||||
$a->redirect($dest . $args);
|
||||
$a->internalRedirect($dest . $args);
|
||||
}
|
||||
}
|
||||
$a->redirect($dest);
|
||||
$a->internalRedirect($dest);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -112,6 +112,6 @@ class Magic extends BaseModule
|
|||
return $ret;
|
||||
}
|
||||
|
||||
$a->redirect($dest);
|
||||
$a->internalRedirect($dest);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,7 +24,7 @@ class Objects extends BaseModule
|
|||
}
|
||||
|
||||
if (!ActivityPub::isRequest()) {
|
||||
$a->redirect(str_replace('objects/', 'display/', $a->query_string));
|
||||
$a->internalRedirect(str_replace('objects/', 'display/', $a->query_string));
|
||||
}
|
||||
|
||||
$item = Item::selectFirst(['id'], ['guid' => $a->argv[1], 'wall' => true, 'private' => false]);
|
||||
|
|
|
@ -49,7 +49,7 @@ class Tos extends BaseModule
|
|||
public static function init()
|
||||
{
|
||||
if (strlen(Config::get('system','singleuser'))) {
|
||||
self::getApp()->redirect('profile/' . Config::get('system','singleuser'));
|
||||
self::getApp()->internalRedirect('profile/' . Config::get('system','singleuser'));
|
||||
}
|
||||
}
|
||||
/**
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue