aboutsummaryrefslogtreecommitdiff
path: root/app/src/main/kotlin/com/pitchedapps/frost/facebook/FbCookie.kt
diff options
context:
space:
mode:
authorAllan Wang <me@allanwang.ca>2021-01-24 19:52:51 -0800
committerAllan Wang <me@allanwang.ca>2021-01-24 19:52:51 -0800
commit4c2c8a9ce4872e8bbb2a55c8b527e4f7b22ef633 (patch)
tree0c77bd9dbca861827b3725c4e5a13618c2efb021 /app/src/main/kotlin/com/pitchedapps/frost/facebook/FbCookie.kt
parent58068ce55e9e203a77c67dfee78fb2658e3bb6aa (diff)
downloadfrost-4c2c8a9ce4872e8bbb2a55c8b527e4f7b22ef633.tar.gz
frost-4c2c8a9ce4872e8bbb2a55c8b527e4f7b22ef633.tar.bz2
frost-4c2c8a9ce4872e8bbb2a55c8b527e4f7b22ef633.zip
Add option to log out for messenger
Diffstat (limited to 'app/src/main/kotlin/com/pitchedapps/frost/facebook/FbCookie.kt')
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/facebook/FbCookie.kt16
1 files changed, 16 insertions, 0 deletions
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 4e932d09..eb3580d4 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/facebook/FbCookie.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/facebook/FbCookie.kt
@@ -110,6 +110,22 @@ class FbCookie(private val prefs: Prefs, private val cookieDao: CookieDao) {
}
}
+ /**
+ * As far as I'm aware there is no way to remove a specific cookie.
+ * As we only care about fb and messenger cookies, this is a workaround
+ * in which we remove all cookies then add back the fb one.
+ */
+ suspend fun removeMessengerCookie() {
+ withContext(Dispatchers.Main + NonCancellable) {
+ val fbCookie = webCookie
+ with(CookieManager.getInstance()) {
+ removeAllCookies()
+ suspendSetWebCookie(FB_COOKIE_DOMAIN, fbCookie)
+ flush()
+ }
+ }
+ }
+
suspend fun switchUser(id: Long) {
val cookie = cookieDao.selectById(id) ?: return L.e { "No cookie for id" }
switchUser(cookie)