logOut() returns error even though successful

When calling logout on my user, it sometimes returns the following error:

Server reported an error: FAULT = '3023' [Unable to logout user due to error: user must be logged in.] <Unable to logout user due to error: user must be logged in.> 

I placed a breakpoint right before I log the user out, and it shows there is a current user. Then I step through the code to when it returns the error, and the user is then logged out.

This suggests that logout is indeed logging out the user properly, however for some reason returning the error.

Note for recreating: This error only occurs when I navigate to another view-controller via a push segue, and the come back to the initial view-controller in the navigation-controller and try to log out.

Hi,

Please clarify: do you call backendless.userService.logout() in segue of the second view controller or in some method of the initial view controller? Do you use sync or async method? Can you add some sample code here?

Regards,
Slava

This may occur if the user-token which your client app has expired. As a result, even though currentUser shows an object, the current session associated with the object is no longer valid. The error is an overkill on our part though, if there is no current session, we should just let the logout proceed (who cares that there is no login). I will create an internal task to relax this rule.

Mark

In the initial view controller I logout the user like so:

  @IBAction func onLogoutButtonTapped(sender: AnyObject) {


    backendless.userService.logout({ (object) -> Void in
      self.performSegueWithIdentifier(self.kSegueMainToSignUp, sender: self)
      self.navigationController?.popToRootViewControllerAnimated(true)
      PushManager.cancelDeviceRegistrationAsync()


      }) { (fault) -> Void in
        print("Server reported an error: \(fault)")
    }
  }