-
Notifications
You must be signed in to change notification settings - Fork 431
Add settings menu to login screen #3940
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: dev
Are you sure you want to change the base?
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -200,20 +200,10 @@ - (void)setupNavigationBar { | |
| if (self.showNavbar) { | ||
| self.navBar = self.navigationController.navigationBar; | ||
| self.navBar.topItem.titleView = [self createTitleItem]; | ||
| // Hides the gear icon if there are no hosts to switch to. | ||
| SFManagedPreferences *managedPreferences = [SFManagedPreferences sharedPreferences]; | ||
| if (managedPreferences.onlyShowAuthorizedHosts && managedPreferences.loginHosts.count == 0) { | ||
| self.config.showSettingsIcon = NO; | ||
| } | ||
|
|
||
| if(self.showSettingsIcon) { | ||
| // Setup right bar button. | ||
| UIBarButtonItem *button = [self createSettingsButton]; | ||
| if (!button.target){ | ||
| [button setTarget:self]; | ||
| } | ||
| if (!button.action){ | ||
| [button setAction:@selector(showLoginHost:)]; | ||
| } | ||
| self.navBar.topItem.rightBarButtonItem = button; | ||
| } | ||
| [self styleNavigationBar:self.navBar]; | ||
|
|
@@ -265,9 +255,53 @@ - (UIBarButtonItem *)createBackButton { | |
|
|
||
| - (UIBarButtonItem *)createSettingsButton { | ||
| UIImage *image = [[SFSDKResourceUtils imageNamed:@"login-window-gear"] imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate]; | ||
| UIBarButtonItem *settingsButton = [[UIBarButtonItem alloc] initWithImage:image style:UIBarButtonItemStylePlain target:self action:@selector(showLoginHost:)]; | ||
| settingsButton.accessibilityLabel = [SFSDKResourceUtils localizedString:@"LOGIN_CHOOSE_SERVER"]; | ||
| settingsButton.accessibilityIdentifier = @"choose connection button"; | ||
|
|
||
| NSMutableArray *menuActions = [[NSMutableArray alloc] initWithCapacity:3]; | ||
|
|
||
| // Don't show the change server option if there are no hosts to switch to. | ||
| SFManagedPreferences *managedPreferences = [SFManagedPreferences sharedPreferences]; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I moved this check to just be around the “Choose Connection” option instead of the settings icon but that would just be for MDM. @wmathurin what do you think about having another property like |
||
| if (!managedPreferences.onlyShowAuthorizedHosts || managedPreferences.loginHosts.count != 0) { | ||
| [menuActions addObject:[UIAction actionWithTitle:[SFSDKResourceUtils localizedString:@"LOGIN_CHOOSE_SERVER"] | ||
| image:nil | ||
| identifier:nil | ||
| handler:^(__kindof UIAction* _Nonnull action) { | ||
| [self showLoginHost:self]; | ||
| }]]; | ||
| } | ||
|
|
||
|
|
||
| [menuActions addObject:[UIAction actionWithTitle:[SFSDKResourceUtils localizedString:@"LOGIN_CLEAR_COOKIES"] | ||
| image:nil | ||
| identifier:nil | ||
| handler:^(__kindof UIAction* _Nonnull action) { | ||
| if ([self.delegate respondsToSelector:@selector(loginViewControllerDidClearCookies:)]) { | ||
| [self.delegate loginViewControllerDidClearCookies:self]; | ||
| } | ||
| }]]; | ||
|
|
||
| [menuActions addObject:[UIAction actionWithTitle:[SFSDKResourceUtils localizedString:@"LOGIN_CLEAR_CACHE"] | ||
| image:nil | ||
| identifier:nil | ||
| handler:^(__kindof UIAction* _Nonnull action) { | ||
| if ([self.delegate respondsToSelector:@selector(loginViewControllerDidClearCache:)]) { | ||
| [self.delegate loginViewControllerDidClearCache:self]; | ||
| } | ||
| }]]; | ||
|
|
||
| [menuActions addObject:[UIAction actionWithTitle:[SFSDKResourceUtils localizedString:@"LOGIN_RELOAD"] | ||
| image:nil | ||
| identifier:nil | ||
| handler:^(__kindof UIAction* _Nonnull action) { | ||
| if ([self.delegate respondsToSelector:@selector(loginViewControllerDidReload:)]) { | ||
| [self.delegate loginViewControllerDidReload:self]; | ||
| } | ||
| }]]; | ||
|
|
||
| UIMenu *menu = [UIMenu menuWithTitle:@"" // No title | ||
| children:menuActions]; | ||
| UIBarButtonItem *settingsButton = [[UIBarButtonItem alloc] initWithImage:image menu:menu]; | ||
| settingsButton.accessibilityLabel = [SFSDKResourceUtils localizedString:@"LOGIN_SETTINGS_BUTTON"]; | ||
| settingsButton.accessibilityIdentifier = @"settings"; | ||
| return settingsButton; | ||
| } | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -730,7 +730,7 @@ - (void)postPushUnregistration:(SFUserAccount *)user logoutReason:(SFLogoutReaso | |
| [self setCurrentUserInternal:nil]; | ||
| } | ||
|
|
||
| [SFSDKWebViewStateManager removeSession]; | ||
| [SFSDKWebViewStateManager resetSessionCookie]; | ||
|
|
||
| //restore these id's inorder to enable post logout cleanup of components | ||
| // TODO: Revisit the userInfo data structure of kSFNotificationUserDidLogout in 7.0. | ||
|
|
@@ -1044,6 +1044,25 @@ - (void)loginViewController:(SFLoginViewController *)loginViewController didChan | |
| [[NSNotificationCenter defaultCenter] postNotification:loginHostChangedNotification]; | ||
| NSString *sceneId = loginViewController.view.window.windowScene.session.persistentIdentifier; | ||
| self.authSessions[sceneId].oauthRequest.loginHost = newLoginHost.host; | ||
| [self restartAuthenticationForViewController:loginViewController]; | ||
| } | ||
|
|
||
| - (void)loginViewControllerDidClearCache:(SFLoginViewController *)loginViewController { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. From this comment about reloading, I used the same restart method as the one that happens after the login host is changed |
||
| [SFSDKWebViewStateManager clearCacheWithCompletionHandler:^{}]; | ||
| [self restartAuthenticationForViewController:loginViewController]; | ||
| } | ||
|
|
||
| - (void)loginViewControllerDidClearCookies:(SFLoginViewController *)loginViewController { | ||
| [SFSDKWebViewStateManager resetSessionCookie]; | ||
| [self restartAuthenticationForViewController:loginViewController]; | ||
| } | ||
|
|
||
| - (void)loginViewControllerDidReload:(SFLoginViewController *)loginViewController { | ||
| [self restartAuthenticationForViewController:loginViewController]; | ||
| } | ||
|
|
||
| - (void)restartAuthenticationForViewController:(SFLoginViewController *)loginViewController { | ||
| NSString *sceneId = loginViewController.view.window.windowScene.session.persistentIdentifier; | ||
| [self restartAuthentication:self.authSessions[sceneId]]; | ||
| } | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I included any type that had cache in the name
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we use:
WKWebsiteDataStore.allWebsiteDataTypes()?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it okay that it would also include the cookies that we have the other method for? Having a way to get rid of everything sounds good to me
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In my mind, it was about starting clean. Let me check the Android code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On Android we are doing
webView.clearCache(true)(see https://github.com/forcedotcom/SalesforceMobileSDK-Android/pull/2752/files#diff-2b4d6c9697f160bfbefe121309b911622ea530d287a7fbc780a872cfd75cd82aR247) which does not clear the cookies.To do everything but the cookies we could do
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds good, updated! I also changed the "Clear Cookies" option to use the method that clears the cookies regardless of the cookie management flag, I was thinking that would be better to make sure it starts clean like you said (let me know if you think I should change it back)