feat(web): initialize frontend
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
$(window).on("load", function () {
|
||||
let authorized = true;
|
||||
if ($.cookie("token") == null) {
|
||||
authorized = false;
|
||||
$.ajax({
|
||||
url: "/token",
|
||||
type: "POST",
|
||||
contentType: "application/json",
|
||||
data: `{"token":"${$.cookie("token")}"}`,
|
||||
dataType: "json",
|
||||
success: function (resp) {
|
||||
if (resp.status) {
|
||||
authorized = true;
|
||||
}
|
||||
},
|
||||
failure: function (err) {
|
||||
alert(err);
|
||||
}
|
||||
});
|
||||
}
|
||||
if (!authorized) {
|
||||
$(location).attr("href", "/auth");
|
||||
}
|
||||
});
|
||||
Reference in New Issue
Block a user