mirror of
https://github.com/ViaVersion/VIAaaS.git
synced 2024-11-28 13:05:16 +01:00
handle null result from prompt(), fetch
This commit is contained in:
parent
1222411fba
commit
5ecb2b49e3
@ -7,7 +7,8 @@ if (urlParams.get("mcauth_success") == "false") {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function askWsUrl() {
|
function askWsUrl() {
|
||||||
let url = prompt("VIAaaS instance websocket", localStorage.getItem("ws-url") || "wss://localhost:25543/ws");
|
let url = localStorage.getItem("ws-url") || "wss://localhost:25543/ws";
|
||||||
|
url = prompt("VIAaaS instance websocket", url) || url;
|
||||||
localStorage.setItem("ws-url", url);
|
localStorage.setItem("ws-url", url);
|
||||||
return url;
|
return url;
|
||||||
}
|
}
|
||||||
@ -25,19 +26,18 @@ function getCorsProxy() {
|
|||||||
|
|
||||||
function loginMc() {
|
function loginMc() {
|
||||||
var clientToken = uuid.v4();
|
var clientToken = uuid.v4();
|
||||||
$.ajax({type: "post",
|
fetch(getCorsProxy() + "https://authserver.mojang.com/authenticate", {method: "post",
|
||||||
url: getCorsProxy() + "https://authserver.mojang.com/authenticate",
|
body: JSON.stringify({
|
||||||
data: JSON.stringify({
|
|
||||||
agent: {name: "Minecraft", version: 1},
|
agent: {name: "Minecraft", version: 1},
|
||||||
username: $("#email").val(),
|
username: $("#email").val(),
|
||||||
password: $("#password").val(),
|
password: $("#password").val(),
|
||||||
clientToken: clientToken,
|
clientToken: clientToken,
|
||||||
}),
|
}),
|
||||||
contentType: "application/json",
|
headers: {"content-type": "application/json"}
|
||||||
dataType: "json"
|
}).then((data) => {
|
||||||
}).done((data) => {
|
if (data.status != 200) throw "not 200";
|
||||||
storeMcAccount(data.accessToken, data.clientToken, data.selectedProfile.name, data.selectedProfile.id);
|
storeMcAccount(data.json().accessToken, data.json().clientToken, data.json().selectedProfile.name, data.json().selectedProfile.id);
|
||||||
}).fail(() => alert("Failed to login"));
|
}).catch(() => alert("Failed to login"));
|
||||||
$("#email").val("");
|
$("#email").val("");
|
||||||
$("#password").val("");
|
$("#password").val("");
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user