Fix the "Not valid credentials" issue caused by trailing separator in server URL (#357)

This commit is contained in:
Ash 2023-03-15 22:43:39 +08:00 committed by GitHub
parent b152c263ac
commit d9b707db80
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 2 deletions

View File

@ -12,8 +12,11 @@ import androidx.compose.material.icons.rounded.RssFeed
import androidx.compose.material3.Icon
import androidx.compose.material3.Text
import androidx.compose.material3.TextButton
import androidx.compose.runtime.*
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.saveable.rememberSaveable
import androidx.compose.runtime.setValue
import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.platform.LocalFocusManager
@ -112,7 +115,9 @@ fun AddFeverAccountDialog(
type = AccountType.Fever,
name = context.getString(R.string.fever),
securityKey = FeverSecurityKey(
serverUrl = serverUrl,
serverUrl = serverUrl
.takeIf { !it.endsWith("/") }
?: serverUrl.trimEnd('/'),
username = username,
password = password,
).toString(),

View File

@ -71,6 +71,8 @@ fun LazyItemScope.FeverConnection(
onConfirm = {
if (securityKey.serverUrl?.isNotBlank() == true) {
securityKey.serverUrl = serverUrlValue
?.takeIf { !it.endsWith("/") }
?: serverUrlValue?.trimEnd('/')
save(account, viewModel, securityKey)
serverUrlDialogVisible = false
}