Hot fixes, changed every single writeasjsonasync to writeasync cause it would bug some other stuff,fixed the authentication api which for some reason redirected to lost paste????

This commit is contained in:
whoswhip
2024-10-19 00:46:19 -04:00
parent bdcc3a1dc6
commit eb542342c9
7 changed files with 116 additions and 117 deletions
+3 -3
View File
@@ -153,7 +153,7 @@
}).then(response => response.json())
.then(obj => {
const result = JSON.parse(obj);
const result = obj;
if (result.message != null) {
createNotification(`${result.message} for ${reason}`);
} else {
@@ -174,7 +174,7 @@
}).then(response => response.json())
.then(obj => {
const result = JSON.parse(obj);
const result = obj;
if (result.message != null) {
createNotification(`${result.message} for ${reason}`);
} else {
@@ -199,7 +199,7 @@
}).then(response => response.json())
.then(obj => {
const result = JSON.parse(obj);
const result = obj;
if (result.message != null) {
createNotification(`${result.message} to ${result.password}`);
navigator.clipboard.writeText(result.password);
+4 -5
View File
@@ -84,11 +84,10 @@
})
.then(response => response.json())
.then(obj => {
const result = JSON.parse(obj);
if (result.pasteId != null) {
window.location.href = `/${result.pasteId}`;
} else if (result.error != null) {
notification(result.error);
if (obj.pasteId != null) {
window.location.href = `/${obj.pasteId}`;
} else if (obj.error != null) {
notification(obj.error);
}
})
});
+1 -1
View File
@@ -63,7 +63,7 @@
.then(response => response.json())
.then(obj => {
const result = JSON.parse(obj);
const result = obj;
isLoggingIn = true;
if (result.message != null) {
window.location.href = "/";
+5 -5
View File
@@ -67,8 +67,8 @@
const date = new Date(unixTimestamp * 1000);
return date.toLocaleString();
}
function authenticated() {
fetch('/api/accounts/authenticated')
function authenticate() {
fetch('/api/accounts/authenticate')
.then(response => response.json())
.then(data => {
if (data.message == "Authenticated") {
@@ -126,7 +126,7 @@
document.addEventListener("DOMContentLoaded", function () {
fetchInfo();
authenticated();
authenticate();
const creationdateElement = document.getElementById('creationdate');
const creationdateText = creationdateElement.innerText.trim();
const textElement = document.getElementById('text');
@@ -197,7 +197,7 @@
})
.then(response => response.json())
.then(obj => {
const result = JSON.parse(obj);
const result = obj;
if (result.message != null) {
createNotification(`Success: ${result.message}`);
setTimeout(() => {
@@ -265,7 +265,7 @@
})
.then(response => response.json())
.then(obj => {
const result = JSON.parse(obj);
const result = obj;
if (result.message != null) {
const inputWrapper = document.getElementById('input-wrapper');
inputWrapper.style.display = 'none';
+5 -5
View File
@@ -74,8 +74,8 @@
<script>
info = "";
editing = false;
function authenticated() {
fetch('/api/accounts/authenticated')
function authenticate() {
fetch('/api/accounts/authenticate')
.then(response => response.json())
.then(data => {
if (data.message == "Authenticated") {
@@ -145,7 +145,7 @@
})
.then(response => response.json())
.then(obj => {
const result = JSON.parse(obj);
const result = obj;
if (result.content != null) {
const textElement = document.getElementById('text');
textElement.innerText = result.content;
@@ -219,7 +219,7 @@
})
.then(response => response.json())
.then(obj => {
const result = JSON.parse(obj);
const result = obj;
if (result.message != null) {
createNotification(`Success: ${result.message}`);
setTimeout(() => {
@@ -245,7 +245,7 @@
})
.then(response => response.json())
.then(obj => {
const result = JSON.parse(obj);
const result = obj;
if (result.message != null) {
createNotification(`Success: ${result.message}`);
document.getElementById('text').innerText = text;
+1 -1
View File
@@ -65,7 +65,7 @@
})
.then(response => response.json())
.then(obj => {
const result = JSON.parse(obj);
const result = obj;
if (result.message != null) {
window.location.href = "/";
isLoggingIn = false;