perf(web): add validate function to js
This commit is contained in:
@@ -0,0 +1 @@
|
||||
$(window).on("load", validate(() => {}, () => $(location).attr("href", "/auth")));
|
||||
@@ -1,4 +1,4 @@
|
||||
$(window).on("load", function () {
|
||||
function validate(onsuccess, onfailure) {
|
||||
let authorized = true;
|
||||
if ($.cookie("token") == null) {
|
||||
authorized = false;
|
||||
@@ -17,7 +17,8 @@ $(window).on("load", function () {
|
||||
}
|
||||
});
|
||||
}
|
||||
if (!authorized) {
|
||||
$(location).attr("href", "/auth");
|
||||
if (authorized) {
|
||||
return onsuccess;
|
||||
}
|
||||
});
|
||||
return onfailure;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user