From 2bd91fb8eb522c0ebc98e07cdc2065aa22ae90a5 Mon Sep 17 00:00:00 2001 From: Gaurav Goel Date: Fri, 8 Nov 2024 10:14:55 +0530 Subject: [PATCH] feat: Update logout function Signed-off-by: Gaurav Goel --- .../com/web3auth/singlefactorauth/SingleFactorAuth.kt | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/singlefactorauth/src/main/java/com/web3auth/singlefactorauth/SingleFactorAuth.kt b/singlefactorauth/src/main/java/com/web3auth/singlefactorauth/SingleFactorAuth.kt index fea9662..8d8fc73 100644 --- a/singlefactorauth/src/main/java/com/web3auth/singlefactorauth/SingleFactorAuth.kt +++ b/singlefactorauth/src/main/java/com/web3auth/singlefactorauth/SingleFactorAuth.kt @@ -214,12 +214,17 @@ class SingleFactorAuth( } } - fun logout(context: Context) { - sessionManager.invalidateSession(context).whenComplete { res, _ -> + fun logout(context: Context): CompletableFuture { + val logoutCF = CompletableFuture() + sessionManager.invalidateSession(context).whenComplete { res, err -> if (res) { SessionManager.deleteSessionIdFromStorage() this.state = null + logoutCF.complete(null) + } else { + logoutCF.completeExceptionally(err) } } + return logoutCF } } \ No newline at end of file