Skip to content

Commit eb3098a

Browse files
authored
Merge pull request #2129 from StoDevX/balances-error-checking
Check for error messages when logging in to olecard/checkbalance
2 parents 10a0a9a + 8687ce1 commit eb3098a

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

source/lib/financials/balances.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,14 @@ async function fetchBalancesFromServer(): Promise<BalancesOrErrorType> {
6060
username: username,
6161
password: password,
6262
})
63-
await fetch(OLECARD_AUTH_URL, {method: 'POST', body: form})
63+
let loginResponse = await fetch(OLECARD_AUTH_URL, {
64+
method: 'POST',
65+
body: form,
66+
})
67+
68+
if (loginResponse.url.includes('message=')) {
69+
return {error: true, value: new Error('login failed!')}
70+
}
6471

6572
const resp: OleCardBalancesType = await fetchJson(OLECARD_DATA_ENDPOINT)
6673

0 commit comments

Comments
 (0)