Skip to content

Commit

Permalink
fix: decode the password correctly.
Browse files Browse the repository at this point in the history
  • Loading branch information
abdallahmehiz committed Dec 17, 2024
1 parent 8011b50 commit fad6a5a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
3 changes: 1 addition & 2 deletions composeApp/src/androidMain/kotlin/utils/AuthRefreshWorker.kt
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,7 @@ class AuthRefreshWorker(
Result.retry()
} else {
val id = authUseCase.getUsername()
val password = Base64.decode(authUseCase.getPassword() ?: throw Exception("User credentials unavailable"))
.toString()
val password = authUseCase.getPassword() ?: throw Exception("User credentials unavailable")
authUseCase.refreshLogin(id, password)
Log.d(TAG, "Token refreshed successfully")
Result.success()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import mehiz.abdallah.progres.data.db.UserAuthTable
import mehiz.abdallah.progres.domain.models.UserAuthModel
import mehiz.abdallah.progres.domain.models.toUserAuthModel
import mehiz.abdallah.progres.domain.models.toUserAuthTable
import kotlin.io.encoding.Base64
import kotlin.io.encoding.ExperimentalEncodingApi
import kotlin.uuid.ExperimentalUuidApi
import kotlin.uuid.Uuid

Expand Down Expand Up @@ -36,8 +38,9 @@ class UserAuthUseCase(
return userAuthDao.getUsername()
}

@OptIn(ExperimentalEncodingApi::class)
suspend fun getPassword(): String? {
return userAuthDao.getBase64EncodedPassword()
return userAuthDao.getBase64EncodedPassword()?.let(Base64::decode)?.decodeToString()
}

suspend fun getToken(): String {
Expand Down

0 comments on commit fad6a5a

Please sign in to comment.