diff --git a/web/public/index.html b/web/public/index.html
index ae869e2..3668a6c 100644
--- a/web/public/index.html
+++ b/web/public/index.html
@@ -26,6 +26,7 @@
+
Welcome to Tanabata!
diff --git a/web/public/js/redirector.js b/web/public/js/redirector.js
new file mode 100644
index 0000000..5e9510a
--- /dev/null
+++ b/web/public/js/redirector.js
@@ -0,0 +1 @@
+$(window).on("load", validate(() => {}, () => $(location).attr("href", "/auth")));
diff --git a/web/public/js/token.js b/web/public/js/token.js
index 5c5e860..7c8acd0 100644
--- a/web/public/js/token.js
+++ b/web/public/js/token.js
@@ -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;
+}