Add new API url with fallback
This commit is contained in:
1 parent
d5e462ba7d
commit
ad818aa314
3 files changed
+31
-22
No files matched your search
@@ -59,11 +59,7 @@ export default class LoginFormUiHandler extends FormModalUiHandler {
|
||||
};
|
||||
if (!this.inputs[0].text)
|
||||
return onFail(i18next.t('menu:emptyUsername'));
|
||||
const contentType = 'application/x-www-form-urlencoded';
|
||||
const headers = {
|
||||
'Content-Type': contentType,
|
||||
};
|
||||
fetch(`${Utils.apiUrl}/account/login`, { method: 'POST', headers: headers, body: `username=${encodeURIComponent(this.inputs[0].text)}&password=${encodeURIComponent(this.inputs[1].text)}` })
|
||||
Utils.apiPost(`account/login`, `username=${this.inputs[0].text}&password=${this.inputs[1].text}`, 'application/x-www-form-urlencoded')
|
||||
.then(response => {
|
||||
if (!response.ok)
|
||||
return response.text();
|
||||
|
||||
@@ -74,15 +74,11 @@ export default class RegistrationFormUiHandler extends FormModalUiHandler {
|
||||
return onFail(this.getReadableErrorMessage('invalid password'));
|
||||
if (this.inputs[1].text !== this.inputs[2].text)
|
||||
return onFail(i18next.t('menu:passwordNotMatchingConfirmPassword'));
|
||||
const contentType = 'application/x-www-form-urlencoded';
|
||||
const headers = {
|
||||
'Content-Type': contentType,
|
||||
};
|
||||
fetch(`${Utils.apiUrl}/account/register`, { method: 'POST', headers: headers, body: `username=${encodeURIComponent(this.inputs[0].text)}&password=${encodeURIComponent(this.inputs[1].text)}` })
|
||||
Utils.apiPost(`account/register`, `username=${encodeURIComponent(this.inputs[0].text)}&password=${encodeURIComponent(this.inputs[1].text)}`, 'application/x-www-form-urlencoded')
|
||||
.then(response => response.text())
|
||||
.then(response => {
|
||||
if (!response) {
|
||||
fetch(`${Utils.apiUrl}/account/login`, { method: 'POST', headers: headers, body: `username=${encodeURIComponent(this.inputs[0].text)}&password=${encodeURIComponent(this.inputs[1].text)}` })
|
||||
Utils.apiPost(`account/login`, `username=${encodeURIComponent(this.inputs[0].text)}&password=${encodeURIComponent(this.inputs[1].text)}`, 'application/x-www-form-urlencoded')
|
||||
.then(response => {
|
||||
if (!response.ok)
|
||||
return response.text();
|
||||
|
||||
Reference in new issue
Block a user