From 678a81a44bd4a4f6212ee6712d8686d43ebfdf19 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kuba=20Szczodrzy=C5=84ski?= Date: Fri, 22 Nov 2019 18:42:11 +0100 Subject: [PATCH] [APIv2/Vulcan] Improve Vulcan login when migrating from APIv1. --- .../pl/szczodrzynski/edziennik/api/v2/vulcan/DataVulcan.kt | 2 +- .../edziennik/api/v2/vulcan/login/VulcanLoginApi.kt | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/api/v2/vulcan/DataVulcan.kt b/app/src/main/java/pl/szczodrzynski/edziennik/api/v2/vulcan/DataVulcan.kt index 1998899a..c48aabe5 100644 --- a/app/src/main/java/pl/szczodrzynski/edziennik/api/v2/vulcan/DataVulcan.kt +++ b/app/src/main/java/pl/szczodrzynski/edziennik/api/v2/vulcan/DataVulcan.kt @@ -172,7 +172,7 @@ class DataVulcan(app: App, profile: Profile?, loginStore: LoginStore) : Data(app "SZ9" -> "http://vulcan.szkolny.eu" else -> null } - return if (url != null) "$url/$symbol" else null + return if (url != null) "$url/$symbol" else loginStore.getLoginData("apiUrl", null) } val fullApiUrl: String? diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/api/v2/vulcan/login/VulcanLoginApi.kt b/app/src/main/java/pl/szczodrzynski/edziennik/api/v2/vulcan/login/VulcanLoginApi.kt index ee81cb9e..8c58f760 100644 --- a/app/src/main/java/pl/szczodrzynski/edziennik/api/v2/vulcan/login/VulcanLoginApi.kt +++ b/app/src/main/java/pl/szczodrzynski/edziennik/api/v2/vulcan/login/VulcanLoginApi.kt @@ -38,10 +38,12 @@ class VulcanLoginApi(val data: DataVulcan, val onSuccess: () -> Unit) { if (data.apiToken?.get(0) == 'F') VULCAN_API_PASSWORD_FAKELOG else VULCAN_API_PASSWORD, data.apiCertificatePfx ?: "" ) - onSuccess() - return@run + data.loginStore.removeLoginData("certificatePfx") } catch (e: Throwable) { e.printStackTrace() + } finally { + onSuccess() + return@run } } if (data.symbol.isNotNullNorEmpty() && data.apiToken.isNotNullNorEmpty() && data.apiPin.isNotNullNorEmpty()) {