Properly encode credentials

This commit is contained in:
Flashfyre 2024-04-18 20:02:04 -04:00
parent 18bd75ca4f
commit a6ddda38ae
2 changed files with 3 additions and 3 deletions

View File

@ -62,7 +62,7 @@ export default class LoginFormUiHandler extends FormModalUiHandler {
const headers = {
'Content-Type': contentType,
};
fetch(`${Utils.apiUrl}/account/login`, { method: 'POST', headers: headers, body: `username=${this.inputs[0].text}&password=${this.inputs[1].text}` })
fetch(`${Utils.apiUrl}/account/login`, { method: 'POST', headers: headers, body: `username=${encodeURIComponent(this.inputs[0].text)}&password=${encodeURIComponent(this.inputs[1].text)}` })
.then(response => {
if (!response.ok)
return response.text();

View File

@ -77,11 +77,11 @@ export default class RegistrationFormUiHandler extends FormModalUiHandler {
const headers = {
'Content-Type': contentType,
};
fetch(`${Utils.apiUrl}/account/register`, { method: 'POST', headers: headers, body: `username=${this.inputs[0].text}&password=${this.inputs[1].text}` })
fetch(`${Utils.apiUrl}/account/register`, { method: 'POST', headers: headers, body: `username=${encodeURIComponent(this.inputs[0].text)}&password=${encodeURIComponent(this.inputs[1].text)}` })
.then(response => response.text())
.then(response => {
if (!response) {
fetch(`${Utils.apiUrl}/account/login`, { method: 'POST', headers: headers, body: `username=${this.inputs[0].text}&password=${this.inputs[1].text}` })
fetch(`${Utils.apiUrl}/account/login`, { method: 'POST', headers: headers, body: `username=${encodeURIComponent(this.inputs[0].text)}&password=${encodeURIComponent(this.inputs[1].text)}` })
.then(response => {
if (!response.ok)
return response.text();