-release
This commit is contained in:
parent
d47c2a2f31
commit
fadce719c7
BIN
Client_v1.apk
Normal file
BIN
Client_v1.apk
Normal file
Binary file not shown.
@ -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
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -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
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user