mirror of
https://github.com/mofeng-git/One-KVM.git
synced 2025-12-13 01:30:31 +08:00
process 401 and 403
This commit is contained in:
parent
b8df7a71fe
commit
18842fdd35
@ -53,6 +53,8 @@ function __loadKvmdInfo() {
|
|||||||
$("kvmd-meta-server-host").innerHTML = "";
|
$("kvmd-meta-server-host").innerHTML = "";
|
||||||
document.title = "Pi-KVM Index";
|
document.title = "Pi-KVM Index";
|
||||||
}
|
}
|
||||||
|
} else if (http.status === 401 || http.status === 403) {
|
||||||
|
document.location.href = "/login";
|
||||||
} else {
|
} else {
|
||||||
setTimeout(__loadKvmdInfo, 1000);
|
setTimeout(__loadKvmdInfo, 1000);
|
||||||
}
|
}
|
||||||
@ -76,7 +78,7 @@ function __makeApp(id, path, icon, name) {
|
|||||||
function __logout() {
|
function __logout() {
|
||||||
var http = tools.makeRequest("POST", "/kvmd/auth/logout", function() {
|
var http = tools.makeRequest("POST", "/kvmd/auth/logout", function() {
|
||||||
if (http.readyState === 4) {
|
if (http.readyState === 4) {
|
||||||
if (http.status === 200) {
|
if (http.status === 200 || http.status === 401 || http.status === 403) {
|
||||||
document.location.href = "/login";
|
document.location.href = "/login";
|
||||||
} else {
|
} else {
|
||||||
wm.error("Logout error:<br>", http.responseText);
|
wm.error("Logout error:<br>", http.responseText);
|
||||||
|
|||||||
@ -46,12 +46,25 @@ function Session() {
|
|||||||
var __startSession = function() {
|
var __startSession = function() {
|
||||||
$("link-led").className = "led-yellow";
|
$("link-led").className = "led-yellow";
|
||||||
$("link-led").title = "Connecting...";
|
$("link-led").title = "Connecting...";
|
||||||
var proto = (location.protocol === "https:" ? "wss" : "ws");
|
|
||||||
__ws = new WebSocket(`${proto}://${location.host}/kvmd/ws`);
|
var http = tools.makeRequest("GET", "/kvmd/auth/check", function() {
|
||||||
__ws.onopen = __wsOpenHandler;
|
if (http.readyState === 4) {
|
||||||
__ws.onmessage = __wsMessageHandler;
|
if (http.status === 200) {
|
||||||
__ws.onerror = __wsErrorHandler;
|
var proto = (location.protocol === "https:" ? "wss" : "ws");
|
||||||
__ws.onclose = __wsCloseHandler;
|
__ws = new WebSocket(`${proto}://${location.host}/kvmd/ws`);
|
||||||
|
__ws.onopen = __wsOpenHandler;
|
||||||
|
__ws.onmessage = __wsMessageHandler;
|
||||||
|
__ws.onerror = __wsErrorHandler;
|
||||||
|
__ws.onclose = __wsCloseHandler;
|
||||||
|
} else if (http.status === 401 || http.status === 403) {
|
||||||
|
wm.error("Unexpected logout occured, please login again").then(function() {
|
||||||
|
document.location.href = "/login";
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
__wsCloseHandler(null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
var __wsOpenHandler = function(event) {
|
var __wsOpenHandler = function(event) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user