From: Kevin Day Date: Thu, 31 Aug 2017 07:19:37 +0000 (-0500) Subject: Bugfix: preserve current login path instead of always redirecting to /u/dashboard X-Git-Url: https://git.kevux.org/?a=commitdiff_plain;h=a3934af187a85c217f7b9e225bbab1c55153875d;p=koopa Bugfix: preserve current login path instead of always redirecting to /u/dashboard If at a given path, such as '/u/view', on login, the default behavior should be to login at that location instead of redirecting to the dashboard. Add missing include file. Use c_standard_paths::URI_DASHBOARD_USER instead of the string '/u/dashboard'. --- diff --git a/common/standard/paths/u/login.php b/common/standard/paths/u/login.php index a56bb11..26b4f3a 100644 --- a/common/standard/paths/u/login.php +++ b/common/standard/paths/u/login.php @@ -14,6 +14,7 @@ require_once('common/base/classes/base_log.php'); require_once('common/standard/classes/standard_index.php'); require_once('common/standard/classes/standard_path.php'); +require_once('common/standard/classes/standard_paths.php'); require_once('common/standard/classes/standard_users.php'); require_once('common/theme/classes/theme_html.php'); @@ -125,25 +126,7 @@ class c_standard_path_user_login extends c_standard_path { } elseif ($login_result === TRUE) { // successfully logged in. - $request_uri = $http->get_request(c_base_http::REQUEST_URI)->get_value_exact(); - if (isset($request_uri['data']) && is_array($request_uri['data'])) { - $destination = $request_uri['data']; - } - else { - $destination = array( - 'scheme' => NULL, - 'authority' => NULL, - 'path' => NULL, - 'query' => NULL, - 'fragment' => NULL, - 'url' => TRUE, - 'current' => $start, - 'invalid' => FALSE, - ); - } - unset($request_uri); - - $destination['path'] = $settings['base_path'] . 'u/dashboard'; + $destination = $this->pr_do_login_redirect(); // note: by using a SEE OTHER redirect, the client knows to make a GET request and that the redirect is temporary. $redirect = c_standard_path::s_create_redirect($destination, c_base_http_status::SEE_OTHER, FALSE); @@ -645,6 +628,34 @@ class c_standard_path_user_login extends c_standard_path { } /** + * Provide a path to redirect to on successful login. + * + * @param c_base_http &$http + * The HTTP settings. + * + * @return array + * A array of destination url parts is always returned. + */ + protected function pr_do_login_redirect() { + $request_uri = $this->http->get_request(c_base_http::REQUEST_URI)->get_value_exact(); + if (isset($request_uri['data']['path'])) { + return $request_uri['data']; + } + unset($request_uri); + + return array( + 'scheme' => NULL, + 'authority' => NULL, + 'path' => $this->settings['base_path'] . c_standard_paths::URI_DASHBOARD_USER, + 'query' => NULL, + 'fragment' => NULL, + 'url' => TRUE, + 'current' => $start, + 'invalid' => FALSE, + ); + } + + /** * Loads LDAP information for the given user (if available). * * @param array $settings