-build apk

-incorrect attempt limit
This commit is contained in:
m-kuchergin 2026-02-25 14:44:21 +03:00
parent ffa49f1420
commit d47c2a2f31
4 changed files with 15 additions and 3 deletions

View File

@ -10,7 +10,10 @@ class CheckAndSaveAuthDataUseCase(
textPassword: String textPassword: String
): Result<Unit> { ): Result<Unit> {
return repository.checkAndSave(textLogin, textPassword).mapCatching { success -> return repository.checkAndSave(textLogin, textPassword).mapCatching { success ->
if (!success) error("Login or password is incorrect") if (!success) {
error("Login or password is incorrect")
}
} }
} }
} }

View File

@ -118,7 +118,11 @@ private fun Content(
if (state.error != null) { if (state.error != null) {
Text( Text(
modifier = Modifier.testTag(TestIds.Auth.ERROR), modifier = Modifier.testTag(TestIds.Auth.ERROR),
text = state.error, text = if (viewModel.incorrectAttemptNum > 5) {
"Превышен лимит попыток входа"
} else {
state.error
},
style = MaterialTheme.typography.bodyMedium, style = MaterialTheme.typography.bodyMedium,
color = Color.Red, color = Color.Red,
) )

View File

@ -27,6 +27,8 @@ class AuthViewModel : ViewModel() {
error = null error = null
) )
) )
var incorrectAttemptNum = 0
val uiState: StateFlow<AuthState> = _uiState.asStateFlow() val uiState: StateFlow<AuthState> = _uiState.asStateFlow()
private val _actionFlow: MutableSharedFlow<AuthAction> = MutableSharedFlow() private val _actionFlow: MutableSharedFlow<AuthAction> = MutableSharedFlow()
@ -46,6 +48,9 @@ class AuthViewModel : ViewModel() {
error = error.message error = error.message
) )
} }
if (error.message == "Login or password is incorrect") {
incorrectAttemptNum += 1;
}
} }
) )
} }
@ -56,7 +61,7 @@ class AuthViewModel : ViewModel() {
oldState.copy( oldState.copy(
isEnabledSend = (checkLoginFormatUseCase.invoke(intent.textLogin) && checkPasswordFormatUseCase.invoke( isEnabledSend = (checkLoginFormatUseCase.invoke(intent.textLogin) && checkPasswordFormatUseCase.invoke(
intent.textLogin, intent.textPassword intent.textLogin, intent.textPassword
)), ) && incorrectAttemptNum <= 5),
error = null error = null
) )
} }

BIN
khBGPU.apk Normal file

Binary file not shown.