1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-23 14:00:56 +01:00

Move invalid session error to login page

Summary:
With invalid session (which happens for me when I change production and dev db but can of course happen in other cases), Phabricator displays an ugly unhandled exception dialog suggesting to logging in again.
But there's no login dialog on that page.

This also changes how users with invalid session are treated on pages not requiring logging.
Previously, an exception was thrown on them. Now they are treated as unlogged users.

Test Plan: Corrupt session, go to /, login.

Reviewers: epriestley

Reviewed By: epriestley

CC: aran

Differential Revision: https://secure.phabricator.com/D2236
This commit is contained in:
vrana 2012-04-13 22:29:32 -07:00
parent d17be1d824
commit ced84470a9
2 changed files with 14 additions and 9 deletions

View file

@ -50,6 +50,20 @@ final class PhabricatorLoginController
return id(new AphrontPlainTextResponse())->setContent($message);
}
$error_view = null;
if ($request->getCookie('phusr') && $request->getCookie('phsid')) {
// The session cookie is invalid, so clear it.
$request->clearCookie('phusr');
$request->clearCookie('phsid');
$error_view = new AphrontErrorView();
$error_view->setTitle('Invalid Session');
$error_view->setErrors(array(
"Your login session is invalid. Try logging in again. If that ".
"doesn't work, clear your browser cookies."
));
}
$next_uri = $this->getRequest()->getPath();
if ($next_uri == '/login/') {
$next_uri = '/';
@ -140,8 +154,6 @@ final class PhabricatorLoginController
$error_view = new AphrontErrorView();
$error_view->setTitle('Login Failed');
$error_view->setErrors($errors);
} else {
$error_view = null;
}
$form = new AphrontFormView();

View file

@ -50,13 +50,6 @@ abstract class PhabricatorController extends AphrontController {
$phsid);
if ($info) {
$user->loadFromArray($info);
} else {
// The session cookie is invalid, so clear it.
$request->clearCookie('phusr');
$request->clearCookie('phsid');
throw new Exception(
"Your login session is invalid. Try logging in again. If that ".
"doesn't work, clear your browser cookies.");
}
}