perf(web): improve authentication

This commit is contained in:
2023-01-28 19:18:11 +03:00
parent 0a76f7fd8e
commit 607cd6df09
6 changed files with 26 additions and 67 deletions
-2
View File
@@ -1,5 +1,3 @@
$(window).on("load", validate(() => $(".btn-secondary").css("display", "block"), () => {}));
$("#auth").on("submit", function submit(e) {
e.preventDefault();
var input_password = $("#password");
-1
View File
@@ -1 +0,0 @@
$(window).on("load", validate(() => {}, () => $(location).attr("href", "/auth")));
-24
View File
@@ -1,24 +0,0 @@
function validate(onsuccess, onfailure) {
let authorized = true;
if ($.cookie("token") == null) {
authorized = false;
} else {
$.ajax({
url: "/token",
type: "POST",
contentType: "application/json",
data: `{"token":"${$.cookie("token")}"}`,
dataType: "json",
success: function (resp) {
authorized = resp.status;
},
failure: function (err) {
alert(err);
}
});
}
if (authorized) {
return onsuccess;
}
return onfailure;
}