@@ -176,6 +176,8 @@ class Web3Auth(web3AuthOptions: Web3AuthOptions, context: Context) : WebViewResu
176176 web3AuthResponse = resp
177177 initializeCf.complete(null )
178178 } else {
179+ SessionManager .deleteSessionIdFromStorage()
180+ sessionManager.setSessionId(" " )
179181 initializeCf.completeExceptionally(error)
180182 }
181183 }
@@ -343,15 +345,15 @@ class Web3Auth(web3AuthOptions: Web3AuthOptions, context: Context) : WebViewResu
343345 val sessionResponse: CompletableFuture <String > =
344346 sessionManager.authorizeSession(origin, context)
345347 sessionResponse.whenComplete { response, error ->
346- if (response.contains( " Error " ) ) {
348+ if (error != null ) {
347349 sessionCompletableFuture.completeExceptionally(
348350 Exception (
349351 Web3AuthError .getError(
350352 ErrorCode .NOUSERFOUND
351353 )
352354 )
353355 )
354- } else if (error == null ) {
356+ } else {
355357 val tempJson = JSONObject (response)
356358 web3AuthResponse = gson.fromJson(tempJson.toString(), Web3AuthResponse ::class .java)
357359 if (web3AuthResponse?.error?.isNotBlank() == true ) {
@@ -371,14 +373,6 @@ class Web3Auth(web3AuthOptions: Web3AuthOptions, context: Context) : WebViewResu
371373 } else {
372374 sessionCompletableFuture.complete(web3AuthResponse)
373375 }
374- } else {
375- sessionCompletableFuture.completeExceptionally(
376- Exception (
377- Web3AuthError .getError(
378- ErrorCode .NOUSERFOUND
379- )
380- )
381- )
382376 }
383377 }
384378 return sessionCompletableFuture
0 commit comments