Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions lib/modules_exec.php
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,7 @@ public function merge_response($request, $session, $page) {
'router_module_list' => $this->site_config->get_modules(),
'router_app_name' => $this->site_config->get('app_name', 'HM3'),
'router_js_exclude_deps' => $this->site_config->get('js_exclude_deps'),
'router_get_export' => $request->get,
));
}
}
Expand Down
8 changes: 4 additions & 4 deletions modules/core/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -433,20 +433,20 @@ function setup_base_page($name, $source=false, $use_layout=true) {
add_output($name, 'js_search_data', true, $source);
add_output($name, 'header_end', false, $source);
add_output($name, 'msgs', false, $source);
add_output($name, 'content_start', false, $source);
add_output($name, 'content_section_start', true, $source);
add_output($name, 'content_section_end', true, $source);
if($use_layout) {
add_output($name, 'content_start', false, $source);
add_output($name, 'login_start', false, $source);
add_output($name, 'login', false, $source);
add_output($name, 'login_end', false, $source);
add_output($name, 'date', true, $source);
add_output($name, 'folder_list_start', true, $source);
add_output($name, 'folder_list_end', true, $source);
add_output($name, 'content_section_start', true, $source);
add_output($name, 'content_section_end', true, $source);
add_output($name, 'modals', true, $source);
add_output($name, 'save_reminder', true, $source);
add_output($name, 'content_end', false, $source, 'page_js', 'after');
}
add_output($name, 'content_end', false, $source, 'page_js', 'after');
add_output($name, 'page_js', false, $source);
}}

Expand Down
8 changes: 8 additions & 0 deletions modules/core/handler_modules.php
Original file line number Diff line number Diff line change
Expand Up @@ -774,6 +774,14 @@ class Hm_Handler_logout extends Hm_Handler_Module {
* Clean up everything on logout
*/
public function process() {
if ($this->request->get['prompt'] ?? false) {
$backQuery = isset($this->request->get['back_query']) ? unserialize(base64_decode($this->request->get['back_query'])): [];

$this->out('cancel_logout_url', '?' . http_build_query($backQuery));

return;
}

if (array_key_exists('logout', $this->request->post) && !$this->session->loaded) {
$this->session->destroy($this->request);
Hm_Msgs::add('Session destroyed on logout', 'info');
Expand Down
4 changes: 4 additions & 0 deletions modules/core/navigation/navigation.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ window.addEventListener('popstate', function(event) {
});

window.addEventListener('load', function() {
if (!hm_is_logged()) {
return;
}

const unMountCallback = renderPage(window.location.href);
history.replaceState({ main: $('#cypht-main').prop('outerHTML'), scripts: extractCustomScripts($(document)) }, "");

Expand Down
6 changes: 5 additions & 1 deletion modules/core/navigation/routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,4 +94,8 @@ Now let's validate and use handlers that are given.
ROUTES = modulesRoutes.filter(route => typeof(window[route.handler]) === 'function').map(route => ({
...route,
handler: window[route.handler]
}))
}));


/* Output routes */
OUTPUT_BARE_ROUTES = ['logout'];
18 changes: 17 additions & 1 deletion modules/core/output_modules.php
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,22 @@ protected function output() {
}
}

class Hm_Output_logout extends Hm_Output_Module {
/**
* Outputs the logout confirmation markup
*/
protected function output() {
$cancelUrl = $this->get('cancel_logout_url', '');
return '<div class="d-flex w-100 justify-content-center align-items-center vh-100 p-3 flex-column">
<p>Do you really want to end the session?</p>
<div class="d-flex gap-2">
<a class="btn btn-primary" href="'.$cancelUrl.'" ' . (!$cancelUrl ? 'style="display:none;"' : '') . '>'.$this->trans('No, go back').'</a>
<a class="btn btn-danger" href="#" id="confirm-logout">'.$this->trans('Yes, log me out').'</a>
</div>
</div>';
}
}

/**
* Start the content section for the servers page
* @subpackage core/output
Expand Down Expand Up @@ -1599,7 +1615,7 @@ class Hm_Output_folder_list_content_end extends Hm_Output_Module {
*/
protected function output() {
$res = '<div class="sidebar-footer">';
$res .= '<a class="logout_link" href="#" title="'. $this->trans('Logout') .'">';
$res .= '<a class="logout_link" href=\'?page=logout&prompt=true&back_query='. (base64_encode(serialize($this->get('router_get_export')))) .'\' title="'. $this->trans('Logout') .'">';
if (!$this->get('hide_folder_icons')) {
$res .= '<i class="bi bi-power menu-icon"></i>';
}
Expand Down
10 changes: 9 additions & 1 deletion modules/core/setup.php
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,11 @@
setup_base_page('notfound');
add_output('notfound', 'notfound_content', true, 'core', 'content_section_start', 'after');

/* logout page */
setup_base_page('logout', 'core', false);
add_handler('logout', 'logout', true, 'core');
add_output('logout', 'logout', true, 'core', 'content_section_start', 'after');

/* message action ajax request */
setup_base_ajax_page('ajax_message_action', 'core');

Expand Down Expand Up @@ -218,7 +223,8 @@
'search',
'ajax_quick_servers_setup',
'ajax_privacy_settings',
'ajax_combined_message_list'
'ajax_combined_message_list',
'logout',
),
'allowed_output' => array(
'date' => array(FILTER_UNSAFE_RAW, false),
Expand Down Expand Up @@ -282,6 +288,8 @@
'sort' => FILTER_SANITIZE_FULL_SPECIAL_CHARS,
'keyword' => FILTER_SANITIZE_FULL_SPECIAL_CHARS,
'screen_emails' => FILTER_SANITIZE_FULL_SPECIAL_CHARS,
'prompt' => FILTER_VALIDATE_BOOLEAN,
'back_query' => FILTER_UNSAFE_RAW,
),

'allowed_post' => array(
Expand Down
2 changes: 1 addition & 1 deletion modules/core/site.js
Original file line number Diff line number Diff line change
Expand Up @@ -1360,7 +1360,7 @@ var Hm_Folders = {
return false;
});
$('.hide_folders').on("click", function() { return Hm_Folders.hide_folder_list(); });
$('.logout_link').on("click", function(e) { return Hm_Utils.confirm_logout(); });
// $('.logout_link').on("click", function(e) { return Hm_Utils.confirm_logout(); });
if (hm_search_terms()) {
$('.search_terms').val(hm_search_terms());
}
Expand Down
Loading