aboutsummaryrefslogtreecommitdiff
path: root/shared
diff options
context:
space:
mode:
authorIsidro Henoch <imhenoch@protonmail.com>2022-01-15 01:10:32 -0600
committerIsidro Henoch <imhenoch@protonmail.com>2022-01-15 01:10:32 -0600
commita48d8624d2ee876eac1fed2d0c32af7dccb4a195 (patch)
tree50c337facc7f2a9aef0ddd08588e167f3d50ebc9 /shared
parent7e27a317fead5a3bda6608bf63a0e3fdf8093fc4 (diff)
downloadetbsa-trackermap-mobile-a48d8624d2ee876eac1fed2d0c32af7dccb4a195.tar.gz
etbsa-trackermap-mobile-a48d8624d2ee876eac1fed2d0c32af7dccb4a195.tar.bz2
etbsa-trackermap-mobile-a48d8624d2ee876eac1fed2d0c32af7dccb4a195.zip
Fixes the 401 error while registering the FCM token
Diffstat (limited to 'shared')
-rw-r--r--shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/apis/SessionApi.kt1
-rw-r--r--shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/controllers/SessionController.kt6
2 files changed, 4 insertions, 3 deletions
diff --git a/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/apis/SessionApi.kt b/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/apis/SessionApi.kt
index 2fba8a8..b57f126 100644
--- a/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/apis/SessionApi.kt
+++ b/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/apis/SessionApi.kt
@@ -107,6 +107,7 @@ class SessionApi(basePath: String = "https://demo.traccar.org/api") : ApiClient(
.flatten()
.find { it.contains("JSESSIONID") }!!
.replace("; Path=/", "")
+ this.token = cookie
val settings = Settings()
settings.putString(ACCESS_TOKEN_KEY, cookie)
(response as Success<*>).data as User
diff --git a/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/controllers/SessionController.kt b/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/controllers/SessionController.kt
index b9cf335..da9b115 100644
--- a/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/controllers/SessionController.kt
+++ b/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/controllers/SessionController.kt
@@ -73,9 +73,9 @@ class SessionController(
loginStateFlow.value = LoginState.Loading
GlobalScope.launch {
try {
- userFlow.value = sessionApi.sessionPost(email, password)
- delay(3000)
- Log.d("LoginViewModel", userFlow.value.toString())
+ val session = sessionApi.sessionPost(email, password)
+ userFlow.value = session
+ usersApi.token = sessionApi.token
token?.let { registerFcmToken(it) }
loginStateFlow.value = LoginState.Success
} catch (e: Exception) {