Loading patches/034-display-back-to-login 0 → 100644 +57 −0 Original line number Diff line number Diff line diff --git a/core/templates/error.php b/core/templates/error.php index 2e5488ae8d..09fbc1e7c4 100644 --- a/core/templates/error.php +++ b/core/templates/error.php @@ -1,13 +1,17 @@ <div class="guest-box"> - <h2><?php p($l->t('Error')) ?></h2> - <ul> - <?php foreach ($_["errors"] as $error):?> - <li> - <p><?php p($error['error']) ?></p> - <?php if (isset($error['hint']) && $error['hint']): ?> - <p class='hint'><?php p($error['hint']) ?></p> - <?php endif;?> - </li> - <?php endforeach ?> - </ul> + <h2><?php p($l->t('Error')) ?></h2> + <ul> + <?php foreach ($_["errors"] as $error):?> + <li> + <p><?php p($error['error']) ?></p> + <?php if (isset($error['hint']) && $error['hint']): ?> + <p class='hint'><?php p($error['hint']) ?></p> + <?php endif;?> + </li> + <?php if ($error['statusCode'] == 401) $displayBackToLogin = true; ?> + <?php endforeach ?> + </ul> + <?php if ($displayBackToLogin): ?> + <a href="<?php print_unescaped($_['logout_url']); ?>"><?php p($l->t('Back to login')) ?></a> + <?php endif; ?> </div> diff --git a/lib/private/legacy/OC_Template.php b/lib/private/legacy/OC_Template.php index 0c9fa1ccc0..d137c7f838 100644 --- a/lib/private/legacy/OC_Template.php +++ b/lib/private/legacy/OC_Template.php @@ -279,7 +279,7 @@ class OC_Template extends \OC\Template\Base { * @param int $statusCode * @suppress PhanAccessMethodInternal */ - public static function printErrorPage($error_msg, $hint = '', $statusCode = 500) { + public static function printErrorPage($error_msg, $hint = '', $statusCode = 500, $logoutUrl = null) { if (\OC::$server->getAppManager()->isEnabledForUser('theming') && !\OC_App::isAppLoaded('theming')) { \OC_App::loadApp('theming'); } @@ -293,8 +293,8 @@ class OC_Template extends \OC\Template\Base { http_response_code($statusCode); try { $content = new \OC_Template('', 'error', 'error', false); - $errors = [['error' => $error_msg, 'hint' => $hint]]; - $content->assign('errors', $errors); + $errors = [['error' => $error_msg, 'hint' => $hint, 'statusCode' => $statusCode]]; + $content->assign('logout_url', $logoutUrl != null ? $logoutUrl : OC_User::getLogoutUrl(\OC::$server->getURLGenerator())); $content->printPage(); } catch (\Exception $e) { $logger = \OC::$server->getLogger(); Loading
patches/034-display-back-to-login 0 → 100644 +57 −0 Original line number Diff line number Diff line diff --git a/core/templates/error.php b/core/templates/error.php index 2e5488ae8d..09fbc1e7c4 100644 --- a/core/templates/error.php +++ b/core/templates/error.php @@ -1,13 +1,17 @@ <div class="guest-box"> - <h2><?php p($l->t('Error')) ?></h2> - <ul> - <?php foreach ($_["errors"] as $error):?> - <li> - <p><?php p($error['error']) ?></p> - <?php if (isset($error['hint']) && $error['hint']): ?> - <p class='hint'><?php p($error['hint']) ?></p> - <?php endif;?> - </li> - <?php endforeach ?> - </ul> + <h2><?php p($l->t('Error')) ?></h2> + <ul> + <?php foreach ($_["errors"] as $error):?> + <li> + <p><?php p($error['error']) ?></p> + <?php if (isset($error['hint']) && $error['hint']): ?> + <p class='hint'><?php p($error['hint']) ?></p> + <?php endif;?> + </li> + <?php if ($error['statusCode'] == 401) $displayBackToLogin = true; ?> + <?php endforeach ?> + </ul> + <?php if ($displayBackToLogin): ?> + <a href="<?php print_unescaped($_['logout_url']); ?>"><?php p($l->t('Back to login')) ?></a> + <?php endif; ?> </div> diff --git a/lib/private/legacy/OC_Template.php b/lib/private/legacy/OC_Template.php index 0c9fa1ccc0..d137c7f838 100644 --- a/lib/private/legacy/OC_Template.php +++ b/lib/private/legacy/OC_Template.php @@ -279,7 +279,7 @@ class OC_Template extends \OC\Template\Base { * @param int $statusCode * @suppress PhanAccessMethodInternal */ - public static function printErrorPage($error_msg, $hint = '', $statusCode = 500) { + public static function printErrorPage($error_msg, $hint = '', $statusCode = 500, $logoutUrl = null) { if (\OC::$server->getAppManager()->isEnabledForUser('theming') && !\OC_App::isAppLoaded('theming')) { \OC_App::loadApp('theming'); } @@ -293,8 +293,8 @@ class OC_Template extends \OC\Template\Base { http_response_code($statusCode); try { $content = new \OC_Template('', 'error', 'error', false); - $errors = [['error' => $error_msg, 'hint' => $hint]]; - $content->assign('errors', $errors); + $errors = [['error' => $error_msg, 'hint' => $hint, 'statusCode' => $statusCode]]; + $content->assign('logout_url', $logoutUrl != null ? $logoutUrl : OC_User::getLogoutUrl(\OC::$server->getURLGenerator())); $content->printPage(); } catch (\Exception $e) { $logger = \OC::$server->getLogger();