Check server status code on account

pull/653/merge
Varun Patil 2023-10-07 09:12:54 -07:00
parent 8b1121fc62
commit 2478dc71fd
1 changed files with 7 additions and 0 deletions

View File

@ -27,6 +27,13 @@ class AccountService(private val mCtx: MainActivity, private val mHttp: HttpServ
fun login(baseUrl: String, loginFlowUrl: String) {
try {
val res = mHttp.postLoginFlow(loginFlowUrl)
// Check if 200 was received
if (res.code != 200) {
throw Exception("Server returned a ${res.code} status code. Please check your reverse proxy configuration and overwriteprotocol is correct.")
}
// Get body as JSON
val body = mHttp.bodyJson(res) ?: throw Exception("Failed to parse login flow response")
// Parse response body as JSON