mirror of
https://github.com/wulkanowy/wulkanowy.git
synced 2024-11-23 06:46:04 -06:00
Fix error handling in login (#2437)
This commit is contained in:
parent
e378b4c70a
commit
d5c17285c1
@ -195,7 +195,7 @@ ext {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
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'
|
coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:2.0.4'
|
||||||
|
|
||||||
|
@ -34,7 +34,7 @@ open class ErrorHandler @Inject constructor(@ApplicationContext protected val co
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected open fun proceed(error: Throwable) {
|
protected open fun proceed(error: Throwable) {
|
||||||
showErrorMessage(context.resources.getErrorString(error), error)
|
showDefaultMessage(error)
|
||||||
when (error) {
|
when (error) {
|
||||||
is PasswordChangeRequiredException -> onPasswordChangeRequired(error.redirectUrl)
|
is PasswordChangeRequiredException -> onPasswordChangeRequired(error.redirectUrl)
|
||||||
is ScramblerException -> onDecryptionFailed()
|
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() {
|
open fun clear() {
|
||||||
showErrorMessage = { _, _ -> }
|
showErrorMessage = { _, _ -> }
|
||||||
onExpiredCredentials = {}
|
onExpiredCredentials = {}
|
||||||
|
@ -62,7 +62,11 @@ class AuthPresenter @Inject constructor(
|
|||||||
}
|
}
|
||||||
isSuccess
|
isSuccess
|
||||||
}
|
}
|
||||||
.onFailure { errorHandler.dispatch(it) }
|
.onFailure {
|
||||||
|
errorHandler.dispatch(it)
|
||||||
|
view?.showProgress(false)
|
||||||
|
view?.showContent(true)
|
||||||
|
}
|
||||||
.onSuccess {
|
.onSuccess {
|
||||||
if (it) {
|
if (it) {
|
||||||
view?.showSuccess(true)
|
view?.showSuccess(true)
|
||||||
|
@ -14,6 +14,7 @@ import io.github.wulkanowy.data.repositories.PreferencesRepository
|
|||||||
import io.github.wulkanowy.data.repositories.StudentRepository
|
import io.github.wulkanowy.data.repositories.StudentRepository
|
||||||
import io.github.wulkanowy.data.resourceFlow
|
import io.github.wulkanowy.data.resourceFlow
|
||||||
import io.github.wulkanowy.domain.adminmessage.GetAppropriateAdminMessageUseCase
|
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.base.BasePresenter
|
||||||
import io.github.wulkanowy.ui.modules.login.LoginData
|
import io.github.wulkanowy.ui.modules.login.LoginData
|
||||||
import io.github.wulkanowy.ui.modules.login.LoginErrorHandler
|
import io.github.wulkanowy.ui.modules.login.LoginErrorHandler
|
||||||
@ -204,6 +205,9 @@ class LoginFormPresenter @Inject constructor(
|
|||||||
}
|
}
|
||||||
.onResourceError {
|
.onResourceError {
|
||||||
loginErrorHandler.dispatch(it)
|
loginErrorHandler.dispatch(it)
|
||||||
|
if (it is InvalidSymbolException) {
|
||||||
|
loginErrorHandler.showDefaultMessage(it)
|
||||||
|
}
|
||||||
lastError = it
|
lastError = it
|
||||||
view?.showContact(true)
|
view?.showContact(true)
|
||||||
analytics.logEvent(
|
analytics.logEvent(
|
||||||
|
@ -3,6 +3,7 @@ package io.github.wulkanowy.utils
|
|||||||
import android.content.res.Resources
|
import android.content.res.Resources
|
||||||
import io.github.wulkanowy.R
|
import io.github.wulkanowy.R
|
||||||
import io.github.wulkanowy.sdk.exception.FeatureNotAvailableException
|
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.CloudflareVerificationException
|
||||||
import io.github.wulkanowy.sdk.scrapper.exception.FeatureDisabledException
|
import io.github.wulkanowy.sdk.scrapper.exception.FeatureDisabledException
|
||||||
import io.github.wulkanowy.sdk.scrapper.exception.ScrapperException
|
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 ServiceUnavailableException -> R.string.error_service_unavailable
|
||||||
is FeatureDisabledException -> R.string.error_feature_disabled
|
is FeatureDisabledException -> R.string.error_feature_disabled
|
||||||
is FeatureNotAvailableException -> R.string.error_feature_not_available
|
is FeatureNotAvailableException -> R.string.error_feature_not_available
|
||||||
|
is AccountInactiveException -> R.string.error_account_inactive
|
||||||
is VulcanException -> R.string.error_unknown_uonet
|
is VulcanException -> R.string.error_unknown_uonet
|
||||||
is ScrapperException -> R.string.error_unknown_app
|
is ScrapperException -> R.string.error_unknown_app
|
||||||
is CloudflareVerificationException -> R.string.error_cloudflare_captcha
|
is CloudflareVerificationException -> R.string.error_cloudflare_captcha
|
||||||
|
@ -66,7 +66,7 @@
|
|||||||
<item>gminaulanmajorat</item>
|
<item>gminaulanmajorat</item>
|
||||||
<item>gminaozorkow</item>
|
<item>gminaozorkow</item>
|
||||||
<item>gminalopiennikgorny</item>
|
<item>gminalopiennikgorny</item>
|
||||||
<item>warszawa</item>
|
<item>saas1</item>
|
||||||
<item>powiatwulkanowy</item>
|
<item>powiatwulkanowy</item>
|
||||||
</string-array>
|
</string-array>
|
||||||
</resources>
|
</resources>
|
||||||
|
@ -852,6 +852,7 @@
|
|||||||
<!--Errors-->
|
<!--Errors-->
|
||||||
<string name="error_no_internet">No internet connection</string>
|
<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_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_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_login_failed">Loading data failed. Please try again later</string>
|
||||||
<string name="error_password_change_required">Register password change required</string>
|
<string name="error_password_change_required">Register password change required</string>
|
||||||
|
Loading…
Reference in New Issue
Block a user