perf(web): add validate function to js

This commit is contained in:
2023-01-27 17:17:47 +03:00
parent 7c58f011ca
commit deb00436f5
3 changed files with 7 additions and 4 deletions
+5 -4
View File
@@ -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;
}