forked from spacebar/spfn-website
Move Generate Token to Backend
This commit is contained in:
parent
fa2c7d9ca5
commit
91882fe4ae
7 changed files with 113 additions and 7 deletions
|
|
@ -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}`)
|
||||
|
|
|
|||
Loading…
Reference in a new issue