main #8

Open
student-m-kuchergin wants to merge 17 commits from KHBGPU-org/NTO-2026-Android-TeamTask-Template:main into main
3 changed files with 9 additions and 6 deletions
Showing only changes of commit 5c0663672f - Show all commits

BIN
Client_v1.apk Normal file

Binary file not shown.

View File

@ -16,13 +16,13 @@ object AuthRepository {
private var codeCache: String? = null private var codeCache: String? = null
suspend fun checkAndSave(textLogin: String, textPassword: String): Result<Boolean> { suspend fun checkAndSave(text: String): Result<Boolean> {
return NetworkDataSource.checkAuth(textLogin, textPassword).onSuccess { success -> return NetworkDataSource.checkAuth(text).onSuccess { success ->
if (success) { if (success) {
codeCache = textLogin // TODO(переделать под отправку и логина и пароля в api) codeCache = text
App.context.userDataStore.edit { preferences -> App.context.userDataStore.edit { preferences ->
val prefKey = stringPreferencesKey(CODE_KEY) val prefKey = stringPreferencesKey(CODE_KEY)
preferences[prefKey] = textLogin // TODO(переделать под отправку и логина и пароля в api) preferences[prefKey] = text
} }
} }
} }

View File

@ -36,9 +36,12 @@ object NetworkDataSource {
} }
} }
suspend fun checkAuth(login: String, password: String): Result<Boolean> = withContext(Dispatchers.IO) { suspend fun checkAuth(text: String): Result<Boolean> = withContext(Dispatchers.IO) {
return@withContext runCatching { return@withContext runCatching {
val response = client.post(getUrl(login, Constants.AUTH_URL)) val response = client.post(
getUrl(text, Constants.AUTH_URL)) {
}
when (response.status) { when (response.status) {
HttpStatusCode.OK -> true HttpStatusCode.OK -> true
else -> false else -> false