Jump to content

Welcome! You're currently a Guest.

If you'd like to join in the Discussion, or access additional features in our forums, please sign in with your Evernote Account here. Have an Evernote Account but forgot your password? Reset it! Don't have an account yet? Create One! You'll need to set your Display Name before your first post.

Photo

iOS SDK after Logout fails isAuthenticated


  • Please log in to reply
1 reply to this topic

#1 AndyDent

AndyDent

  • PipPipPip
  • Title: Bushwhacker
  • Group: Members
  • 144 posts

Posted 29 June 2012 - 08:48 PM

I'm getting a crash after calling [[EvernoteSession sharedSession] logout] because isAuthenticated is drilling down into trying to retrieve credentials when I later check. When I say "later" I mean, even on a subsequent run of the program.

I think EvernoteSession::authenticationToken should be rewritten as:


- (NSString *)authenticationToken
{
if (self.credentials)
  return [self.credentials authenticationToken];
return nil;
}



In detail

EvernoteSession.m contains
- (void)logout
{
// remove all credentials from the store and keychain
[self.credentialStore clearAllCredentials];

// remove the store from user defaults
[self.credentialStore delete];
}


- (BOOL)isAuthenticated
{
return (self.authenticationToken != nil);
}

This on the face of it looked completely logical.

When I try to check isAuthenticated after my app has logged out, authenticationToken calls down to the credential store without checking if it exists:

- (NSString *)authenticationToken
{
return [[self credentials] authenticationToken];
}

- (ENCredentials *)credentials
{
	return [self.credentialStore credentialsForHost:self.host];
}

and ends up throwing an exception from
EDAMUserStoreClient getUser: (NSString *) authenticationToken

GetUser_result(success:(null),userException:EDAMUserException(errorCode:5,parameter:"authenticationToken"),systemException:(null))

#2 SethH

SethH

  • Title: Evernote Employee
  • Group: Evernote Employee
  • 683 posts

Posted 10 July 2012 - 04:48 AM

Hi Andy, sorry for the slow response on this. I don't think that the problem is coming from the SDK - the credential store doesn't make a call to UserStore.getUser. To try to reproduce this, I modified our sample app's iPhoneViewController logout method to make a call to isAuthenticated:


- (IBAction)logout:(id)sender {
    [[EvernoteSession sharedSession] logout];
    [self updateButtonsForAuthentication];
    if ([[EvernoteSession sharedSession] isAuthenticated]) {
        NSLog(@"isAuthenticated after logout");
    }
}


If the call to isAuthenticated caused the crash, then I'd expect the app to crash here, which it doesn't, nor is the NSLog message written - isAuthenticated returns false.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

Clip to Evernote