Merge pull request #972 from D-storm/master
Feature Request #1460 Redirect to login page after session has expired
This commit is contained in:
commit
b87a38f9c9
@ -339,6 +339,9 @@ var AJAX = {
|
||||
PMA_ajaxShowMessage(data.error, false);
|
||||
AJAX.active = false;
|
||||
AJAX.xhr = null;
|
||||
if (data.redirect_url) {
|
||||
window.location.href=data.redirect_url;
|
||||
}
|
||||
}
|
||||
},
|
||||
/**
|
||||
|
||||
@ -75,33 +75,10 @@ class AuthenticationCookie extends AuthenticationPlugin
|
||||
if ($response->isAjax()) {
|
||||
$response->isSuccess(false);
|
||||
|
||||
$login_link = '<br /><br />[ ' .
|
||||
sprintf(
|
||||
'<a href="%s" class="ajax login-link">%s</a>',
|
||||
$GLOBALS['cfg']['PmaAbsoluteUri'],
|
||||
__('Log in')
|
||||
)
|
||||
. ' ]';
|
||||
|
||||
if (! empty($conn_error)) {
|
||||
|
||||
$conn_error .= $login_link;
|
||||
|
||||
$response->addJSON(
|
||||
'message',
|
||||
PMA_Message::error(
|
||||
$conn_error
|
||||
)
|
||||
);
|
||||
} else {
|
||||
$response->addJSON(
|
||||
'message',
|
||||
PMA_Message::error(
|
||||
__('Your session has expired. Please log in again.') .
|
||||
$login_link
|
||||
)
|
||||
);
|
||||
}
|
||||
$response->addJSON(
|
||||
'redirect_url',
|
||||
$GLOBALS['cfg']['PmaAbsoluteUri']
|
||||
);
|
||||
if (defined('TESTSUITE')) {
|
||||
return true;
|
||||
} else {
|
||||
|
||||
@ -77,11 +77,8 @@ class PMA_AuthenticationCookie_Test extends PHPUnit_Framework_TestCase
|
||||
$mockResponse->expects($this->once())
|
||||
->method('addJSON')
|
||||
->with(
|
||||
'message',
|
||||
PMA_Message::error(
|
||||
'1<br /><br />[ <a href="https://phpmyadmin.net/" ' .
|
||||
'class="ajax login-link">Log in</a> ]'
|
||||
)
|
||||
'redirect_url',
|
||||
'https://phpmyadmin.net/'
|
||||
);
|
||||
|
||||
$attrInstance = new ReflectionProperty('PMA_Response', '_instance');
|
||||
@ -94,39 +91,7 @@ class PMA_AuthenticationCookie_Test extends PHPUnit_Framework_TestCase
|
||||
);
|
||||
// Case 2
|
||||
|
||||
$mockResponse = $this->getMockBuilder('PMA_Response')
|
||||
->disableOriginalConstructor()
|
||||
->setMethods(array('isAjax', 'isSuccess', 'addJSON'))
|
||||
->getMock();
|
||||
|
||||
$mockResponse->expects($this->once())
|
||||
->method('isAjax')
|
||||
->with()
|
||||
->will($this->returnValue(true));
|
||||
|
||||
$mockResponse->expects($this->once())
|
||||
->method('isSuccess')
|
||||
->with(false);
|
||||
|
||||
$mockResponse->expects($this->once())
|
||||
->method('addJSON')
|
||||
->with(
|
||||
'message',
|
||||
PMA_Message::error(
|
||||
'Your session has expired. Please log in again.' .
|
||||
'<br /><br />[ <a href="https://phpmyadmin.net/" ' .
|
||||
'class="ajax login-link">Log in</a> ]'
|
||||
)
|
||||
);
|
||||
|
||||
$attrInstance = new ReflectionProperty('PMA_Response', '_instance');
|
||||
$attrInstance->setAccessible(true);
|
||||
$attrInstance->setValue(null, $mockResponse);
|
||||
$GLOBALS['conn_error'] = '';
|
||||
|
||||
$this->assertTrue(
|
||||
$this->object->auth()
|
||||
);
|
||||
|
||||
// case 3
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user