mirror of
https://github.com/etesync/android
synced 2025-02-22 20:42:04 +00:00
Fix debug log for failed login attempts.
Before this fix a failed loging attempt wouldn't include any debug information on why it failed. This commit fixes that.
This commit is contained in:
parent
032abfaa60
commit
cdc5afba61
@ -23,8 +23,6 @@ import java.net.URI
|
|||||||
import java.util.*
|
import java.util.*
|
||||||
|
|
||||||
class BaseConfigurationFinder(protected val context: Context, protected val credentials: LoginCredentials) {
|
class BaseConfigurationFinder(protected val context: Context, protected val credentials: LoginCredentials) {
|
||||||
|
|
||||||
protected val logBuffer = StringHandler()
|
|
||||||
protected var httpClient: OkHttpClient
|
protected var httpClient: OkHttpClient
|
||||||
|
|
||||||
init {
|
init {
|
||||||
@ -33,7 +31,7 @@ class BaseConfigurationFinder(protected val context: Context, protected val cred
|
|||||||
|
|
||||||
|
|
||||||
fun findInitialConfiguration(): Configuration {
|
fun findInitialConfiguration(): Configuration {
|
||||||
var failed = false
|
var exception: Throwable? = null
|
||||||
val cardDavConfig = findInitialConfiguration(CollectionInfo.Type.ADDRESS_BOOK)
|
val cardDavConfig = findInitialConfiguration(CollectionInfo.Type.ADDRESS_BOOK)
|
||||||
val calDavConfig = findInitialConfiguration(CollectionInfo.Type.CALENDAR)
|
val calDavConfig = findInitialConfiguration(CollectionInfo.Type.CALENDAR)
|
||||||
|
|
||||||
@ -44,18 +42,17 @@ class BaseConfigurationFinder(protected val context: Context, protected val cred
|
|||||||
authtoken = authenticator.getAuthToken(credentials.userName, credentials.password)
|
authtoken = authenticator.getAuthToken(credentials.userName, credentials.password)
|
||||||
} catch (e: Exceptions.HttpException) {
|
} catch (e: Exceptions.HttpException) {
|
||||||
Logger.log.warning(e.message)
|
Logger.log.warning(e.message)
|
||||||
|
exception = e
|
||||||
failed = true
|
|
||||||
} catch (e: IOException) {
|
} catch (e: IOException) {
|
||||||
Logger.log.warning(e.message)
|
Logger.log.warning(e.message)
|
||||||
failed = true
|
exception = e
|
||||||
}
|
}
|
||||||
|
|
||||||
return Configuration(
|
return Configuration(
|
||||||
credentials.uri,
|
credentials.uri,
|
||||||
credentials.userName, authtoken,
|
credentials.userName, authtoken,
|
||||||
cardDavConfig, calDavConfig,
|
cardDavConfig, calDavConfig,
|
||||||
logBuffer.toString(), failed
|
exception
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -72,12 +69,13 @@ class BaseConfigurationFinder(protected val context: Context, protected val cred
|
|||||||
class Configuration
|
class Configuration
|
||||||
// We have to use URI here because HttpUrl is not serializable!
|
// We have to use URI here because HttpUrl is not serializable!
|
||||||
|
|
||||||
(val url: URI, val userName: String, val authtoken: String?, val cardDAV: ServiceInfo, val calDAV: ServiceInfo, val logs: String, val isFailed: Boolean) : Serializable {
|
(val url: URI, val userName: String, val authtoken: String?, val cardDAV: ServiceInfo, val calDAV: ServiceInfo, var error: Throwable?) : Serializable {
|
||||||
var rawPassword: String? = null
|
var rawPassword: String? = null
|
||||||
var password: String? = null
|
var password: String? = null
|
||||||
var keyPair: Crypto.AsymmetricKeyPair? = null
|
var keyPair: Crypto.AsymmetricKeyPair? = null
|
||||||
|
|
||||||
var error: Throwable? = null
|
val isFailed: Boolean
|
||||||
|
get() = this.error != null
|
||||||
|
|
||||||
class ServiceInfo : Serializable {
|
class ServiceInfo : Serializable {
|
||||||
val collections: Map<String, CollectionInfo> = HashMap()
|
val collections: Map<String, CollectionInfo> = HashMap()
|
||||||
|
@ -50,7 +50,7 @@ class DetectConfigurationFragment : DialogFragment(), LoaderManager.LoaderCallba
|
|||||||
if (data.isFailed)
|
if (data.isFailed)
|
||||||
// no service found: show error message
|
// no service found: show error message
|
||||||
fragmentManager!!.beginTransaction()
|
fragmentManager!!.beginTransaction()
|
||||||
.add(NothingDetectedFragment.newInstance(data.logs), null)
|
.add(NothingDetectedFragment.newInstance(data.error!!.localizedMessage), null)
|
||||||
.commitAllowingStateLoss()
|
.commitAllowingStateLoss()
|
||||||
else
|
else
|
||||||
// service found: continue
|
// service found: continue
|
||||||
|
@ -56,7 +56,7 @@ class LoginCredentialsChangeFragment : DialogFragment(), LoaderManager.LoaderCal
|
|||||||
if (data.isFailed)
|
if (data.isFailed)
|
||||||
// no service found: show error message
|
// no service found: show error message
|
||||||
fragmentManager!!.beginTransaction()
|
fragmentManager!!.beginTransaction()
|
||||||
.add(NothingDetectedFragment.newInstance(data.logs), null)
|
.add(NothingDetectedFragment.newInstance(data.error!!.localizedMessage), null)
|
||||||
.commitAllowingStateLoss()
|
.commitAllowingStateLoss()
|
||||||
else {
|
else {
|
||||||
val settings: AccountSettings
|
val settings: AccountSettings
|
||||||
|
Loading…
Reference in New Issue
Block a user