convert logout modal to ajax request

pull/3051/head
Andrew Bauer 2020-09-19 10:44:05 -05:00
parent 03a0e849b8
commit 7c1ec4f957
3 changed files with 22 additions and 2 deletions

View File

@ -33,6 +33,10 @@ global $CLANG;
</div>
<div class="modal-footer">
<form name="logoutForm" id="logoutForm" method="post" action="?">
<?php
// We have to manually insert the csrf key into the form when using a modal generated via ajax call
echo getCSRFinputHTML();
?>
<input type="hidden" name="view" value="logout"/>
<button type="submit" name="action" value="logout"><?php echo translate('Logout') ?></button>
<?php if ( ZM_USER_SELF_EDIT ) echo '<button type="submit" name="action" value="config">'.translate('Config').'</button>'.PHP_EOL; ?>

View File

@ -702,8 +702,6 @@ function getHeaderFlipHTML() {
// Returns the html representing the logged in user name and avatar
function getAcctCircleHTML($skin, $user=null) {
// Include Logout modal
include("skins/$skin/views/logout.php");
$result = '';
if ( ZM_OPT_USE_AUTH and $user ) {

View File

@ -312,6 +312,9 @@ if ( currentView != 'none' && currentView != 'login' ) {
$j.ajaxSetup({timeout: AJAX_TIMEOUT}); //sets timeout for all getJSON.
$j(document).ready(function() {
// Load the lgoout modal into the dom
getLogoutModal();
// Trigger autorefresh of the widget bar stats on the navbar
if ( $j('.navbar').length ) {
setInterval(getNavBar, navBarRefresh);
@ -746,3 +749,18 @@ function enoperm() {
console.log("Response Text: " + jqxhr.responseText);
});
}
function getLogoutModal() {
$j.getJSON(thisUrl + '?request=modal&modal=logout')
.done(function(data) {
if ( $j('#modalLogout').length ) {
$j('#modalLogout').replaceWith(data.html);
} else {
$j("body").append(data.html);
}
})
.fail(function(jqxhr, textStatus, error) {
console.log("Request Failed: " + textStatus + ", " + error);
console.log("Response Text: " + jqxhr.responseText);
});
}