fix: display an error if StartMessenger fails

This commit is contained in:
Richard Ramos 2022-12-01 18:26:16 -04:00 committed by RichΛrd
parent 4d5ef972bf
commit 7261c78650
5 changed files with 32 additions and 7 deletions

View File

@ -103,6 +103,7 @@ proc buildAndRegisterUserProfile(self: AppController)
# Startup Module Delegate Interface
proc startupDidLoad*(self: AppController)
proc userLoggedIn*(self: AppController)
proc logout*(self: AppController)
proc storeKeyPairForNewKeycardUser*(self: AppController)
# Main Module Delegate Interface
@ -369,6 +370,9 @@ proc userLoggedIn*(self: AppController) =
if not self.startupModule.isNil:
self.startupModule.delete
proc logout*(self: AppController) =
self.generalService.logout()
proc buildAndRegisterLocalAccountSensitiveSettings(self: AppController) =
var pubKey = self.settingsService.getPublicKey()
singletonInstance.localAccountSensitiveSettings.setFileName(pubKey)

View File

@ -28,6 +28,9 @@ method moveToLoadingAppState*(self: AccessInterface) {.base.} =
method moveToAppState*(self: AccessInterface) {.base.} =
raise newException(ValueError, "No implementation available")
method moveToStartupState*(self: AccessInterface) {.base.} =
raise newException(ValueError, "No implementation available")
method onBackActionClicked*(self: AccessInterface) {.base.} =
raise newException(ValueError, "No implementation available")

View File

@ -118,6 +118,9 @@ method moveToLoadingAppState*[T](self: Module[T]) =
method moveToAppState*[T](self: Module[T]) =
self.view.setAppState(AppState.MainAppState)
method moveToStartupState*[T](self: Module[T]) =
self.view.setAppState(AppState.StartupState)
method startUpUIRaised*[T](self: Module[T]) =
self.view.startUpUIRaised()
@ -284,7 +287,16 @@ method onNodeLogin*[T](self: Module[T], error: string) =
quit() # quit the app
if error.len == 0:
self.delegate.userLoggedIn()
try:
self.delegate.userLoggedIn()
except Exception as e:
let errDescription = e.msg
error "error: ", errDescription
self.delegate.logout()
self.moveToStartupState()
self.emitAccountLoginError(errDescription)
return
if currStateObj.flowType() != FlowType.AppLogin:
self.controller.storeIdentityImage()
self.controller.cleanTmpData()

View File

@ -23,12 +23,10 @@ proc init*(self: Service) =
createDir(app_constants.ROOTKEYSTOREDIR)
proc startMessenger*(self: Service) =
try:
discard status_general.startMessenger()
except Exception as e:
let errDesription = e.msg
error "error: ", errDesription
return
discard status_general.startMessenger()
proc logout*(self: Service) =
discard status_general.logout()
proc getPasswordStrengthScore*(self: Service, password, userName: string): int =
try:

View File

@ -22,6 +22,14 @@ proc startMessenger*(): RpcResponse[JsonNode] {.raises: [Exception].} =
let payload = %* []
result = core.callPrivateRPC("startMessenger".prefix, payload)
proc logout*(): RpcResponse[JsonNode] {.raises: [Exception].} =
try:
let response = status_go.logout()
result.result = Json.decode(response, JsonNode)
except RpcException as e:
error "error logging out", methodName = "logout", exception=e.msg
raise newException(RpcException, e.msg)
proc generateSymKeyFromPassword*(password: string): RpcResponse[JsonNode] {.raises: [Exception].} =
let payload = %* [password]
result = core.callPrivateRPC("waku_generateSymKeyFromPassword", payload)