From 039d7a7c199c4d991dd143f3b096a0707100f6a3 Mon Sep 17 00:00:00 2001 From: Allan Wang Date: Sun, 12 Sep 2021 19:54:31 -0700 Subject: Fix multi account switching --- .../com/pitchedapps/frost/facebook/FbCookie.kt | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) (limited to 'app/src/main/kotlin/com/pitchedapps/frost/facebook/FbCookie.kt') diff --git a/app/src/main/kotlin/com/pitchedapps/frost/facebook/FbCookie.kt b/app/src/main/kotlin/com/pitchedapps/frost/facebook/FbCookie.kt index ea1b0946..1a714374 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/facebook/FbCookie.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/facebook/FbCookie.kt @@ -48,8 +48,11 @@ class FbCookie @Inject internal constructor( ) { companion object { - private const val FB_COOKIE_DOMAIN = HTTPS_FACEBOOK_COM - private const val MESSENGER_COOKIE_DOMAIN = HTTPS_MESSENGER_COM + /** + * Domain information. Dot prefix still matters for Android browsers. + */ + private const val FB_COOKIE_DOMAIN = ".$FACEBOOK_COM" + private const val MESSENGER_COOKIE_DOMAIN = ".$MESSENGER_COM" } /** @@ -135,22 +138,24 @@ class FbCookie @Inject internal constructor( * Helper function to remove the current cookies * and launch the proper login page */ - suspend fun logout(context: Context) { + suspend fun logout(context: Context, deleteCookie: Boolean = true) { val cookies = arrayListOf() if (context is Activity) cookies.addAll(context.cookies().filter { it.id != prefs.userId }) - logout(prefs.userId) + logout(prefs.userId, deleteCookie) context.launchLogin(cookies, true) } /** * Clear the cookies of the given id */ - suspend fun logout(id: Long) { + suspend fun logout(id: Long, deleteCookie: Boolean = true) { L.d { "Logging out user" } - cookieDao.deleteById(id) - L.d { "Fb cookie deleted" } - L._d { id } + if (deleteCookie) { + cookieDao.deleteById(id) + L.d { "Fb cookie deleted" } + L._d { id } + } reset() } -- cgit v1.2.3