perf(web): improve authentication
This commit is contained in:
@@ -26,7 +26,6 @@
|
||||
<link rel="stylesheet" href="/css/auth.css">
|
||||
<script src="/js/jquery-3.6.0.min.js"></script>
|
||||
<script src="/js/jquery.cookie.js"></script>
|
||||
<script src="/js/token.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<header>
|
||||
|
||||
@@ -24,9 +24,6 @@
|
||||
<link rel="stylesheet" href="/css/bootstrap.min.css">
|
||||
<link rel="stylesheet" href="/css/general.css">
|
||||
<script src="/js/jquery-3.6.0.min.js"></script>
|
||||
<script src="/js/jquery.cookie.js"></script>
|
||||
<script src="/js/token.js"></script>
|
||||
<script src="/js/redirector.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Welcome to Tanabata!</h1>
|
||||
|
||||
@@ -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