Skip to content
This repository has been archived by the owner on Aug 16, 2023. It is now read-only.

How remove tokens / logout user ? #92

Closed
iMedHelmi opened this issue Apr 16, 2015 · 3 comments
Closed

How remove tokens / logout user ? #92

iMedHelmi opened this issue Apr 16, 2015 · 3 comments

Comments

@iMedHelmi
Copy link

Hi, I'm using SimpleAuth/FacebookWeb and SimpleAuth/TwitterWeb in my new app. I want to know what is the easiest/safest way to remove tokens in order to logout a user ? I want to be able to prompt the login interface each time and not just use stored accounts. Can you please help me figure it out ? Thanks.

@mergesort
Copy link

@iMedHelmi SimpleAuth doesn't store login tokens for you, it's up to you to know whether the user is logged in. I'd recommend storing the tokens you receive in the keychain, so not anyone can see them, and when you want to log out a user, remove them from the keychain.

@iMedHelmi
Copy link
Author

Thank you @mergesort for your answer. The thing is, once a user is logged in, when I call [SimpleAuth authorize:@"facebook-web" completion:^(id responseObject, NSError *error)], the modal login controller is presented and immediately dismesses returning the last logged in user data. I though SimpleAuth stores somewhere the access tokens. So is it something related to cache in the webview ?

@iMedHelmi
Copy link
Author

Hi. I ended up adding the following code to SimpleAuthWebViewController's viewDidLoad and it worked like a charm.

//Set Cache
NSURLCache *sharedCache = [[NSURLCache alloc] initWithMemoryCapacity:0 diskCapacity:0 diskPath:nil];
 [NSURLCache setSharedURLCache:sharedCache];
    
//Clear All Cookies
for (NSHTTPCookie *cookie in [[NSHTTPCookieStorage sharedHTTPCookieStorage] cookies]) {
        [[NSHTTPCookieStorage sharedHTTPCookieStorage] deleteCookie:cookie];
 }

Thank you @mergesort :)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants