diff --git a/js/ajax.js b/js/ajax.js index 303a6eea78..3ebe9b5283 100644 --- a/js/ajax.js +++ b/js/ajax.js @@ -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; + } } }, /** diff --git a/libraries/plugins/auth/AuthenticationCookie.class.php b/libraries/plugins/auth/AuthenticationCookie.class.php index d418d41c78..eddc937b73 100644 --- a/libraries/plugins/auth/AuthenticationCookie.class.php +++ b/libraries/plugins/auth/AuthenticationCookie.class.php @@ -75,33 +75,10 @@ class AuthenticationCookie extends AuthenticationPlugin if ($response->isAjax()) { $response->isSuccess(false); - $login_link = '

[ ' . - sprintf( - '%s', - $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 { diff --git a/test/classes/plugin/auth/PMA_AuthenticationCookie_test.php b/test/classes/plugin/auth/PMA_AuthenticationCookie_test.php index 29a822f18c..f86978e5d0 100644 --- a/test/classes/plugin/auth/PMA_AuthenticationCookie_test.php +++ b/test/classes/plugin/auth/PMA_AuthenticationCookie_test.php @@ -77,11 +77,8 @@ class PMA_AuthenticationCookie_Test extends PHPUnit_Framework_TestCase $mockResponse->expects($this->once()) ->method('addJSON') ->with( - 'message', - PMA_Message::error( - '1

[ Log in ]' - ) + '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.' . - '

[ Log in ]' - ) - ); - - $attrInstance = new ReflectionProperty('PMA_Response', '_instance'); - $attrInstance->setAccessible(true); - $attrInstance->setValue(null, $mockResponse); - $GLOBALS['conn_error'] = ''; - - $this->assertTrue( - $this->object->auth() - ); // case 3