1
0
mirror of https://github.com/wulkanowy/wulkanowy.git synced 2024-11-23 03:16:48 -06:00

Fix error handling in login (#2437)

This commit is contained in:
Mikołaj Pich 2024-02-25 16:37:28 +01:00 committed by GitHub
parent e378b4c70a
commit d5c17285c1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 19 additions and 4 deletions

View File

@ -195,7 +195,7 @@ ext {
}
dependencies {
implementation 'io.github.wulkanowy:sdk:2.4.1'
implementation 'io.github.wulkanowy:sdk:2.4.2-SNAPSHOT'
coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:2.0.4'

View File

@ -34,7 +34,7 @@ open class ErrorHandler @Inject constructor(@ApplicationContext protected val co
}
protected open fun proceed(error: Throwable) {
showErrorMessage(context.resources.getErrorString(error), error)
showDefaultMessage(error)
when (error) {
is PasswordChangeRequiredException -> onPasswordChangeRequired(error.redirectUrl)
is ScramblerException -> onDecryptionFailed()
@ -45,6 +45,10 @@ open class ErrorHandler @Inject constructor(@ApplicationContext protected val co
}
}
fun showDefaultMessage(error: Throwable) {
showErrorMessage(context.resources.getErrorString(error), error)
}
open fun clear() {
showErrorMessage = { _, _ -> }
onExpiredCredentials = {}

View File

@ -62,7 +62,11 @@ class AuthPresenter @Inject constructor(
}
isSuccess
}
.onFailure { errorHandler.dispatch(it) }
.onFailure {
errorHandler.dispatch(it)
view?.showProgress(false)
view?.showContent(true)
}
.onSuccess {
if (it) {
view?.showSuccess(true)

View File

@ -14,6 +14,7 @@ import io.github.wulkanowy.data.repositories.PreferencesRepository
import io.github.wulkanowy.data.repositories.StudentRepository
import io.github.wulkanowy.data.resourceFlow
import io.github.wulkanowy.domain.adminmessage.GetAppropriateAdminMessageUseCase
import io.github.wulkanowy.sdk.scrapper.login.InvalidSymbolException
import io.github.wulkanowy.ui.base.BasePresenter
import io.github.wulkanowy.ui.modules.login.LoginData
import io.github.wulkanowy.ui.modules.login.LoginErrorHandler
@ -204,6 +205,9 @@ class LoginFormPresenter @Inject constructor(
}
.onResourceError {
loginErrorHandler.dispatch(it)
if (it is InvalidSymbolException) {
loginErrorHandler.showDefaultMessage(it)
}
lastError = it
view?.showContact(true)
analytics.logEvent(

View File

@ -3,6 +3,7 @@ package io.github.wulkanowy.utils
import android.content.res.Resources
import io.github.wulkanowy.R
import io.github.wulkanowy.sdk.exception.FeatureNotAvailableException
import io.github.wulkanowy.sdk.scrapper.exception.AccountInactiveException
import io.github.wulkanowy.sdk.scrapper.exception.CloudflareVerificationException
import io.github.wulkanowy.sdk.scrapper.exception.FeatureDisabledException
import io.github.wulkanowy.sdk.scrapper.exception.ScrapperException
@ -33,6 +34,7 @@ fun Resources.getErrorString(error: Throwable): String = when (error) {
is ServiceUnavailableException -> R.string.error_service_unavailable
is FeatureDisabledException -> R.string.error_feature_disabled
is FeatureNotAvailableException -> R.string.error_feature_not_available
is AccountInactiveException -> R.string.error_account_inactive
is VulcanException -> R.string.error_unknown_uonet
is ScrapperException -> R.string.error_unknown_app
is CloudflareVerificationException -> R.string.error_cloudflare_captcha

View File

@ -66,7 +66,7 @@
<item>gminaulanmajorat</item>
<item>gminaozorkow</item>
<item>gminalopiennikgorny</item>
<item>warszawa</item>
<item>saas1</item>
<item>powiatwulkanowy</item>
</string-array>
</resources>

View File

@ -852,6 +852,7 @@
<!--Errors-->
<string name="error_no_internet">No internet connection</string>
<string name="error_invalid_device_datetime">An error occurred. Check your device clock</string>
<string name="error_account_inactive">This account is inactive. Try logging in again</string>
<string name="error_timeout">Connection to register failed. Servers can be overloaded. Please try again later</string>
<string name="error_login_failed">Loading data failed. Please try again later</string>
<string name="error_password_change_required">Register password change required</string>