Skip to content

Commit

Permalink
Fixed good logout
Browse files Browse the repository at this point in the history
  • Loading branch information
josaphatim committed Jul 17, 2024
1 parent 93698fa commit faf1408
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 8 deletions.
4 changes: 2 additions & 2 deletions modules/core/output_modules.php
Original file line number Diff line number Diff line change
Expand Up @@ -363,10 +363,10 @@ protected function output() {
$res .= '<div class="d-none position-fixed top-0 end-0 mt-3 me-3 sys_messages'.$logged_out_class.'">';
foreach ($msgs as $msg) {
if (preg_match("/ERR/", $msg)) {
$res .= sprintf('<div class="alert alert-danger alert-dismissible fade show" role="alert"><i class="bi bi-exclamation-triangle me-2"></i><span class="danger" id="sys_messages">%s</span>', $this->trans(mb_substr((string) $msg, 3)));
$res .= sprintf('<div class="alert alert-danger alert-dismissible fade show" role="alert"><i class="bi bi-exclamation-triangle me-2"></i><span class="danger">%s</span>', $this->trans(mb_substr((string) $msg, 3)));
}
else {
$res .= sprintf('<div class="alert alert-success alert-dismissible fade show" role="alert"><i class="bi bi-check-circle me-2"></i><span class="info" id="sys_messages">%s</span>', $this->trans($msg));
$res .= sprintf('<div class="alert alert-success alert-dismissible fade show" role="alert"><i class="bi bi-check-circle me-2"></i><span class="info">%s</span>', $this->trans($msg));
}
$res .= '<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button></div>';
}
Expand Down
2 changes: 1 addition & 1 deletion modules/core/site.js
Original file line number Diff line number Diff line change
Expand Up @@ -1435,7 +1435,7 @@ var Hm_Utils = {
},

confirm_logout: function() {
if ($('#unsaved_changes').val() == 0) {
if (! $('#unsaved_changes').length || $('#unsaved_changes').val() == 0) {
document.getElementById('logout_without_saving').click();
}
else {
Expand Down
2 changes: 1 addition & 1 deletion tests/phpunit/modules/core/output_modules.php
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ public function test_msgs() {
$test = new Output_Test('msgs', 'core');
$test->handler_response = array('router_login_state' => false);
$res = $test->run();
$this->assertEquals(array('<div class="d-none position-fixed top-0 end-0 mt-3 me-3 sys_messages logged_out"><div class="alert alert-danger alert-dismissible fade show" role="alert"><i class="bi bi-exclamation-triangle me-2"></i><span class="danger" id="sys_messages">foo</span><button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button></div><div class="alert alert-success alert-dismissible fade show" role="alert"><i class="bi bi-check-circle me-2"></i><span class="info" id="sys_messages">foo</span><button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button></div></div>'), $res->output_response);
$this->assertEquals(array('<div class="d-none position-fixed top-0 end-0 mt-3 me-3 sys_messages logged_out"><div class="alert alert-danger alert-dismissible fade show" role="alert"><i class="bi bi-exclamation-triangle me-2"></i><span class="danger">foo</span><button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button></div><div class="alert alert-success alert-dismissible fade show" role="alert"><i class="bi bi-check-circle me-2"></i><span class="info">foo</span><button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button></div></div>'), $res->output_response);
}
/**
* @preserveGlobalState disabled
Expand Down
7 changes: 3 additions & 4 deletions tests/selenium/login.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,9 @@ def good_login(self):
assert self.by_class('content_title') != None

def good_logout(self):
self.wait(By.CLASS_NAME, "logout_link")
self.logout_no_save()
self.logout()
self.wait()
assert self.by_id('sys_messages').text == 'Session destroyed on logout'
assert 'Session destroyed on logout' in self.by_class('sys_messages').text



Expand All @@ -61,5 +60,5 @@ def good_logout(self):
'missing_username_and_password',
'bad_login_key',
'good_login',
# 'good_logout'
'good_logout'
])

0 comments on commit faf1408

Please sign in to comment.