Skip to content
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

Log UA marker only if browser auth completed #1991

Merged
merged 2 commits into from Apr 12, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -59,11 +59,9 @@ - (void)viewWillAppear:(BOOL)animated {

// Set the size of this view so any popover controller will resize to fit
CGRect r = [self.tableView rectForSection:0];

CGSize size = CGSizeMake(380, r.size.height);
self.preferredContentSize = size;
self.loginHostListViewController.preferredContentSize = size;

self.preferredContentSize = size;

// Make sure to also set the content size of the other view controller, otherwise the popover won't
Expand All @@ -77,7 +75,8 @@ - (void)viewWillAppear:(BOOL)animated {
* Invoked when the user taps on the done button to add the login host to the list of hosts.
*/
- (void)addNewServer:(id)sender {
[self.loginHostListViewController addLoginHost:[SFSDKLoginHost hostWithName:self.name.text host:self.server.text deletable:YES]];
[self.loginHostListViewController addLoginHost:[SFSDKLoginHost hostWithName:self.name.text host:[self.server.text stringByTrimmingCharactersInSet:
[NSCharacterSet whitespaceCharacterSet]] deletable:YES]];
}

#pragma mark - Table view data source
Expand All @@ -104,7 +103,6 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N
cell.textField.keyboardType = UIKeyboardTypeURL;
cell.textField.autocapitalizationType = UITextAutocapitalizationTypeNone;
self.server = cell.textField;

[cell.textField becomeFirstResponder];
} else {
cell.textField.placeholder = [SFSDKResourceUtils localizedString:@"LOGIN_SERVER_NAME"];
Expand Down
Expand Up @@ -298,13 +298,11 @@ - (void)revokeAuthentication {
- (void)setAdvancedAuthState:(SFOAuthAdvancedAuthState)advancedAuthState {
if (_advancedAuthState != advancedAuthState) {
_advancedAuthState = advancedAuthState;

// Re-trigger the native browser flow if the app becomes active on `SFOAuthAdvancedAuthStateBrowserRequestInitiated` state.
if (_advancedAuthState == SFOAuthAdvancedAuthStateBrowserRequestInitiated) {
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(handleAppDidBecomeActiveDuringAdvancedAuth:) name:UIApplicationDidBecomeActiveNotification object:nil];
[SFSDKAppFeatureMarkers registerAppFeature:kSFAppFeatureSafariBrowserForLogin];
}
else {
} else {
[[NSNotificationCenter defaultCenter] removeObserver:self name:UIApplicationDidBecomeActiveNotification object:nil];
}
}
Expand All @@ -315,26 +313,23 @@ - (BOOL)handleAdvancedAuthenticationResponse:(NSURL *)appUrlResponse {
[self log:SFLogLevelInfo format:@"%@ Current advanced auth state (%@) not compatible with handling app launch auth response.", NSStringFromSelector(_cmd), [[self class] advancedAuthStateDesc:self.advancedAuthState]];
return NO;
}

[SFSDKAppFeatureMarkers registerAppFeature:kSFAppFeatureSafariBrowserForLogin];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you want this where the advanced browser flow has actually fully completed? This isn't quite there.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No - only when the browser portion is complete. This is good enough.

NSString *appUrlResponseString = [appUrlResponse absoluteString];
if (![[appUrlResponseString lowercaseString] hasPrefix:[self.credentials.redirectUri lowercaseString]]) {
[self log:SFLogLevelInfo format:@"%@ URL does not match redirect URI.", NSStringFromSelector(_cmd)];
return NO;
}

NSString *query = [appUrlResponse query];
if ([query length] == 0) {
[self log:SFLogLevelInfo format:@"%@ URL has no query string.", NSStringFromSelector(_cmd)];
return NO;
}

NSDictionary *queryDict = [[self class] parseQueryString:query decodeParams:NO];
NSString *codeVal = queryDict[kSFOAuthResponseTypeCode];
if ([codeVal length] == 0) {
[self log:SFLogLevelInfo format:@"%@ URL has no '%@' parameter value.", NSStringFromSelector(_cmd), kSFOAuthResponseTypeCode];
return NO;
}

self.approvalCode = codeVal;
[self log:SFLogLevelInfo format:@"%@ Received advanced authentication response. Beginning token exchange.", NSStringFromSelector(_cmd)];
self.advancedAuthState = SFOAuthAdvancedAuthStateTokenRequestInitiated;
Expand Down