No need to login without password and username.
This commit is contained in:
parent
7f0ba193ec
commit
c4c92e6dd9
@ -4,6 +4,7 @@ import bou.amine.apps.readerforselfossv2.model.*
|
|||||||
import bou.amine.apps.readerforselfossv2.service.AppSettingsService
|
import bou.amine.apps.readerforselfossv2.service.AppSettingsService
|
||||||
import io.github.aakira.napier.Napier
|
import io.github.aakira.napier.Napier
|
||||||
import io.ktor.client.*
|
import io.ktor.client.*
|
||||||
|
import io.ktor.client.call.*
|
||||||
import io.ktor.client.plugins.*
|
import io.ktor.client.plugins.*
|
||||||
import io.ktor.client.plugins.cache.*
|
import io.ktor.client.plugins.cache.*
|
||||||
import io.ktor.client.plugins.contentnegotiation.*
|
import io.ktor.client.plugins.contentnegotiation.*
|
||||||
@ -76,10 +77,14 @@ class SelfossApi(private val appSettingsService: AppSettingsService) {
|
|||||||
private fun hasLoginInfo() = appSettingsService.getUserName() != null && appSettingsService.getPassword() != null
|
private fun hasLoginInfo() = appSettingsService.getUserName() != null && appSettingsService.getPassword() != null
|
||||||
|
|
||||||
suspend fun login(): SuccessResponse =
|
suspend fun login(): SuccessResponse =
|
||||||
if (shouldHavePostLogin()) {
|
if (appSettingsService.getUserName().isNotEmpty() && appSettingsService.getPassword().isNotEmpty()) {
|
||||||
postLogin()
|
if (shouldHavePostLogin()) {
|
||||||
|
postLogin()
|
||||||
|
} else {
|
||||||
|
getLogin()
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
getLogin()
|
SuccessResponse(true)
|
||||||
}
|
}
|
||||||
|
|
||||||
private suspend fun getLogin() = maybeResponse(client.get(url("/login")) {
|
private suspend fun getLogin() = maybeResponse(client.get(url("/login")) {
|
||||||
|
Loading…
Reference in New Issue
Block a user