perf(web): improve authentication
This commit is contained in:
@@ -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 +0,0 @@
|
||||
$(window).on("load", validate(() => {}, () => $(location).attr("href", "/auth")));
|
||||
@@ -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;
|
||||
}
|
||||
Reference in New Issue
Block a user