update google-callback.html, repository.go, script.js, telegram-callback.html

This commit is contained in:
redtea committed 2024-10-23 12:00:00 +03:00
1 parent ecfac68f89
commit d73a4f44cb
4 files changed
+227

No files matched your search

+33
View File
@@ -0,0 +1,33 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Login</title>
<script defer>
function bodyLoad() {
if (localStorage.getItem("token") != null) checkToken(localStorage.getItem("token"));
else window.location.href = window.location.href.replace("google-callback", "google-callback-process")
}
function checkToken(token) {
console.log("Checking token...")
const xhr = new XMLHttpRequest();
xhr.open('GET', 'https://auth.easystartup.su/api/user/self', true);
xhr.setRequestHeader('Authorization', `Bearer ${token}`);
xhr.setRequestHeader('Content-Type', 'application/json');
xhr.onload = function() {
if(xhr.status == 200) {
console.log("Status 200")
let ans = JSON.parse(xhr.responseText)
if(ans.google_id == "") window.location.href = window.location.href.replace("google-callback", "google-callback-process") + "&usertoken=" + token
else window.location.href = window.location.href.replace("google-callback", "google-callback-process")
} else window.location.href = window.location.href.replace("google-callback", "google-callback-process")
};
xhr.onerror = function() {
console.log('Network error');
};
xhr.send();
}
</script>
</head>
<body onload="bodyLoad()"><</body>