Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Changing to remove *all* cookies on logout

  • Loading branch information...
commit 16aa7f5cef5433f1c0cc0e124bdbcc63d72e5a00 1 parent 1827d7e
Kevin Hawkins khawkins authored
22 hybrid/SalesforceHybridSDK/SalesforceHybridSDK/Plugins/SFOAuthPlugin/SalesforceOAuthPlugin.m
View
@@ -87,10 +87,10 @@ Adds the access (session) token cookie to the web view, for authentication.
- (void)addSidCookieForDomain:(NSString*)domain;
/**
- Removes any Salesforce cookies from the cookie store. Cookies are reset with
+ Removes any cookies from the cookie store. All app cookies are reset with
new authentication.
*/
-- (void)removeSalesforceCookies;
+- (void)removeCookies;
/**
Convert the post-authentication credentials into a Dictionary, to return to
@@ -363,8 +363,8 @@ - (void)login
- (void)logout
{
- // Clear any Salesforce-related cookie state.
- [self removeSalesforceCookies];
+ // Clear any cookies set by the app.
+ [self removeCookies];
// Revoke all stored OAuth authentication.
[self.coordinator revokeAuthentication];
@@ -379,9 +379,9 @@ - (void)logout
- (void)loggedIn
{
- // First, remove any cookies associated with Salesforce domains (.salesforce.com, .force.com).
- // Salesforce-based cookies should be reset with any new authentication (user agent, refresh, etc.).
- [self removeSalesforceCookies];
+ // First, remove any cookies associated with the app.
+ // All cookies should be reset with any new authentication (user agent, refresh, etc.).
+ [self removeCookies];
[self addSidCookieForDomain:@".salesforce.com"];
self.lastRefreshCompleted = [NSDate date];
@@ -399,16 +399,12 @@ - (void)loggedIn
}
}
-- (void)removeSalesforceCookies
+- (void)removeCookies
{
NSHTTPCookieStorage *cookieStorage = [NSHTTPCookieStorage sharedHTTPCookieStorage];
NSArray *fullCookieList = [NSArray arrayWithArray:[cookieStorage cookies]];
for (NSHTTPCookie *cookie in fullCookieList) {
- if ([[[cookie domain] lowercaseString] hasSuffix:@".salesforce.com"]
- || [[[cookie domain] lowercaseString] hasSuffix:@".force.com"])
- {
- [cookieStorage deleteCookie:cookie];
- }
+ [cookieStorage deleteCookie:cookie];
}
}

1 comment on commit 16aa7f5

Wolfgang Mathurin
Owner

Looks good.

Please sign in to comment.
Something went wrong with that request. Please try again.