-build apk
-incorrect attempt limit
This commit is contained in:
parent
ffa49f1420
commit
d47c2a2f31
@ -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")
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -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,
|
||||||
)
|
)
|
||||||
|
|||||||
@ -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
BIN
khBGPU.apk
Normal file
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user