Move Generate Token to Backend

This commit is contained in:
BloxerHD 2026-06-23 19:36:04 +01:00
commit 91882fe4ae
Signed by: bloxerhd018
SSH key fingerprint: SHA256:ItSfcfhpXlfkMK3uQSDYW5X3XKm0hbHWQqWcCK57px8
7 changed files with 113 additions and 7 deletions

View file

@ -12,18 +12,17 @@ function loginError(message, code = null) {
}
async function generateToken(username, password) {
const credentials = btoa(`${username} ${password}`);
const body = `grant_type=password&username=${username}&password=${password}&client_id=website`
let response;
try {
response = await fetch("https://account.spfn.net/api/v2/oauth2/generate_token", {
response = await fetch("/api/v1/login/generate_token", {
method: "POST",
headers: {
"Content-Type": "application/x-www-form-urlencoded"
"Content-Type": "application/json",
},
body,
body: JSON.stringify({
username,
password,
}),
})
} catch (err) {
loginError(`Internal Server Error: ${err.message}`)