[fix] Fixed the issue of freezing when entering the client without configuring the private key

This commit is contained in:
acite
2025-08-25 19:10:05 +08:00
parent 49c00c54ba
commit 1632c8b2fb
2 changed files with 4 additions and 2 deletions

View File

@@ -9,9 +9,10 @@ import java.security.PrivateKey
import java.security.Signature
object AuthManager {
suspend fun fetchToken(baseUrl: String, username: String, privateKey: String): String? = runBlocking {
suspend fun fetchToken(baseUrl: String, username: String, privateKey: String): String? {
val api = ApiClient.api
var challengeBase64 = ""
try{
challengeBase64 = api.getChallenge(username).string()
}catch (e: Exception)
@@ -21,7 +22,7 @@ object AuthManager {
val signedBase64 = signChallenge(db64(privateKey), db64(challengeBase64))
return@runBlocking try {
return try {
api.verifyChallenge(username, ChallengeResponse(response = signedBase64)).string()
} catch (e: Exception) {
e.printStackTrace()