feat: Refactor login screen - fix compilation error
This commit is contained in:
@@ -155,6 +155,7 @@ fun LabelEntity.toDomainLabelOut(): LabelOut {
|
||||
return LabelOut(
|
||||
id = this.id,
|
||||
name = this.name,
|
||||
description = null, // Not available in LabelEntity
|
||||
color = "", // Not available in LabelEntity
|
||||
isArchived = false, // Not available in LabelEntity
|
||||
createdAt = "", // Not available in LabelEntity
|
||||
|
||||
@@ -119,6 +119,7 @@ fun LabelOutDto.toDomain(): DomainLabelOut {
|
||||
return DomainLabelOut(
|
||||
id = this.id,
|
||||
name = this.name,
|
||||
description = this.description,
|
||||
color = this.color ?: "",
|
||||
isArchived = this.isArchived ?: false,
|
||||
createdAt = this.createdAt,
|
||||
|
||||
@@ -98,11 +98,46 @@ class CredentialsRepositoryImpl @Inject constructor(
|
||||
*/
|
||||
override suspend fun getToken(): String? {
|
||||
return withContext(Dispatchers.IO) {
|
||||
Timber.d("[DEBUG][ACTION][getting_token] Getting auth token.")
|
||||
encryptedPrefs.getString(KEY_AUTH_TOKEN, null)
|
||||
val token = encryptedPrefs.getString(KEY_AUTH_TOKEN, null)
|
||||
if (token != null) {
|
||||
Timber.i("[INFO][ACTION][token_retrieved] Auth token retrieved successfully.")
|
||||
} else {
|
||||
Timber.w("[WARN][FALLBACK][no_token_found] No auth token found.")
|
||||
}
|
||||
token
|
||||
}
|
||||
}
|
||||
// [END_ENTITY: Function('getToken')]
|
||||
|
||||
// [ENTITY: Function('clearAllCredentials')]
|
||||
/**
|
||||
* @summary Очищает все сохраненные учетные данные и токены.
|
||||
* @sideeffect Удаляет все записи, связанные с учетными данными, из SharedPreferences.
|
||||
*/
|
||||
override suspend fun clearAllCredentials() {
|
||||
withContext(Dispatchers.IO) {
|
||||
Timber.i("[INFO][ACTION][clearing_all_credentials] Clearing all saved credentials and tokens.")
|
||||
encryptedPrefs.edit()
|
||||
.remove(KEY_SERVER_URL)
|
||||
.remove(KEY_USERNAME)
|
||||
.remove(KEY_PASSWORD)
|
||||
.remove(KEY_AUTH_TOKEN)
|
||||
.apply()
|
||||
}
|
||||
}
|
||||
// [END_ENTITY: Function('clearAllCredentials')]
|
||||
|
||||
// [ENTITY: Function('areCredentialsSavedSync')]
|
||||
/**
|
||||
* @summary Synchronously checks if user credentials are saved.
|
||||
* @return true if all essential credentials (URL, username, password) are present, false otherwise.
|
||||
*/
|
||||
override fun areCredentialsSavedSync(): Boolean {
|
||||
return encryptedPrefs.contains(KEY_SERVER_URL) &&
|
||||
encryptedPrefs.contains(KEY_USERNAME) &&
|
||||
encryptedPrefs.contains(KEY_PASSWORD)
|
||||
}
|
||||
// [END_ENTITY: Function('areCredentialsSavedSync')]
|
||||
}
|
||||
// [END_ENTITY: Class('CredentialsRepositoryImpl')]
|
||||
// [END_FILE_CredentialsRepositoryImpl.kt]
|
||||
|
||||
Reference in New Issue
Block a user