function LogOut(makeRequest = true) { if (!makeRequest) { // User is already unauthorized; just clean up the storage and redirect to Login page window.localStorage.clear(); redirectTo('login'); } else { var apiRequest = initAPIRequest('post', 'logout', 'Logout'); var callUrl = apiUri['baseurl'] + apiUri[apiRequest.endpoint]; $.ajax({ url: callUrl, type: apiRequest.method, data: apiRequest.body, headers: apiRequest.headers, contentType: 'application/json', dataType: 'json', xhrFields: { withCredentials: true }, success: function(data, status, xhr) { window.localStorage.clear(); redirectTo('login'); }, error: function (xhr, status, error) { console.log('Logout failed: ', xhr); alert(HTTPServiceCodes['unexpected'].replace(/http_status/gi, xhr.status).replace(/http_status/gi, xhr.statusText)); } }); } }