Skip to content
This repository has been archived by the owner on May 6, 2024. It is now read-only.

Commit

Permalink
Social Flow fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
saeedbashir committed Jun 25, 2018
1 parent f316856 commit 4ff9007
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 16 deletions.
2 changes: 1 addition & 1 deletion Source/OEXFBSocial.m
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ - (void)logout {
- (void)requestUserProfileInfoWithCompletion:(void (^)(NSDictionary*, NSError *))completion {
if([FBSDKAccessToken currentAccessToken])
{
[[[FBSDKGraphRequest alloc]initWithGraphPath:@"me" parameters:nil] startWithCompletionHandler:^(FBSDKGraphRequestConnection *connection, id result, NSError *error) {
[[[FBSDKGraphRequest alloc]initWithGraphPath:@"me" parameters:@{@"fields": @"name,email"}] startWithCompletionHandler:^(FBSDKGraphRequestConnection *connection, id result, NSError *error) {
completion(result, error);
}];
}
Expand Down
11 changes: 5 additions & 6 deletions Source/OEXLoginViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -259,8 +259,6 @@ - (void)handleActivationDuringLogin {
[self.btn_Login applyButtonStyleWithStyle:[self.environment.styles filledPrimaryButtonStyle] withTitle:[self signInButtonText]];
[self.activityIndicator stopAnimating];
[self.view setUserInteractionEnabled:YES];

self.authProvider = nil;
}
}

Expand All @@ -274,8 +272,6 @@ - (void)setSignInToDefaultState:(NSNotification*)notification {
else if(![facebookManager isLogin] && [self.authProvider isKindOfClass:[OEXFacebookAuthProvider class]]) {
[self handleActivationDuringLogin];
}

self.authProvider = nil;
[[OEXGoogleSocial sharedInstance] setHandledOpenUrl:NO];
}

Expand Down Expand Up @@ -418,9 +414,12 @@ - (void)handleLoginResponseWith:(NSData*)data response:(NSURLResponse*)response
else if(httpResp.statusCode == OEXHTTPStatusCode426UpgradeRequired) {
[self showUpdateRequiredMessage];
}
else if (httpResp.statusCode == OEXHTTPStatusCode400BadRequest) {
NSString *errorMessage = [Strings authProviderErrorWithAuthProvider:self.authProvider.displayName platformName:self.environment.config.platformName];
[self loginFailedWithErrorMessage:errorMessage title:nil];
}
else if(httpResp.statusCode >= 400 && httpResp.statusCode <= 500) {
NSString* errorStr = [Strings invalidUsernamePassword];
[self loginFailedWithErrorMessage:errorStr title:nil];
[self loginFailedWithErrorMessage:[Strings invalidUsernamePassword] title:nil];
}
else {
dispatch_async(dispatch_get_main_queue(), ^{
Expand Down
18 changes: 13 additions & 5 deletions Source/OEXRegistrationViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ - (void)toggleOptionalFields:(id)sender {
#pragma mark ExternalRegistrationOptionsDelegate

- (void)optionsView:(OEXExternalRegistrationOptionsView *)view choseProvider:(id<OEXExternalAuthProvider>)provider {
[provider authorizeServiceFromController:self requestingUserDetails:YES withCompletion:^(NSString *accessToken, OEXRegisteringUserDetails *userProfile, NSError *error) {
[provider authorizeServiceFromController:self requestingUserDetails:YES withCompletion:^(NSString *accessToken, OEXRegisteringUserDetails *userDetails, NSError *error) {
if(error == nil) {
[view beginIndicatingActivity];
self.view.userInteractionEnabled = NO;
Expand All @@ -361,10 +361,7 @@ - (void)optionsView:(OEXExternalRegistrationOptionsView *)view choseProvider:(id
}];
}
else {
// No account already, so continue registration process
UIView* headingView = [[OEXUsingExternalAuthHeadingView alloc] initWithFrame:CGRectZero serviceName:provider.displayName];
[self useHeadingView:headingView];
[self receivedFields:userProfile fromProvider:provider withAccessToken:accessToken];
[self configureViewForSocial:provider accessToken:accessToken userDetails:userDetails];
}
}];
}
Expand All @@ -379,6 +376,17 @@ - (void)optionsView:(OEXExternalRegistrationOptionsView *)view choseProvider:(id
}];
}

- (void) configureViewForSocial:(id<OEXExternalAuthProvider>)provider accessToken:(NSString *) accessToken userDetails:(OEXRegisteringUserDetails *) userDetails {
// No account already, so continue registration process
__block OEXRegistrationViewController *blockSelf = self;

dispatch_async(dispatch_get_main_queue(), ^{
UIView* headingView = [[OEXUsingExternalAuthHeadingView alloc] initWithFrame:CGRectZero serviceName:provider.displayName];
[blockSelf useHeadingView:headingView];
[blockSelf receivedFields:userDetails fromProvider:provider withAccessToken:accessToken];
});
}

- (void)receivedFields:(OEXRegisteringUserDetails*)profile fromProvider:(id <OEXExternalAuthProvider>)provider withAccessToken:(NSString*)accessToken {
self.externalAccessToken = accessToken;
self.externalProvider = provider;
Expand Down
4 changes: 0 additions & 4 deletions Source/OEXUserDetails.m
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,6 @@ - (id)initWithUserDictionary:(NSDictionary*)userDetailsDictionary {
_userId = [userDetailsDictionary objectForKey:OEXUserDetailsUserIdKey];
_name = [userDetailsDictionary objectForKey:OEXUserDetailsNameKey];
_url = [userDetailsDictionary objectForKey:OEXUserDetailsUrlKey];

if ([_name isKindOfClass:[NSNull class]]) {
_name = @"";
}
}

return self;
Expand Down
2 changes: 2 additions & 0 deletions Source/en.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,8 @@
"APP_REVIEW.MESSAGE_SUBJECT" = "Customer Review";
/*Asteric for marking fields required*/
"ASTERIC" = "*";
/* This error message will be shown if user tried to login with third party (facebook/google) and server returns 400 status code*/
"AUTH_PROVIDER_ERROR" = "This {auth_provider} account is not linked with any {platform_name} account. Please register.";
/*Subtitle for bulk download view when in new, partial or downloaded state - {count} is single video*/
"BULK_DOWNLOAD_VIDEOS_SUB_TITLE##{one}" = "{count} Video, {videos_size}MB total";
/*Subtitle for bulk download view when in new, partial or downloaded state - {count} is number of videos*/
Expand Down
2 changes: 2 additions & 0 deletions Source/es-419.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,8 @@
"APP_REVIEW.MESSAGE_SUBJECT" = "Crítica del cliente";
/*Asteric for marking fields required*/
"ASTERIC" = "*";
/* This error message will be shown if user tried to login with third party (facebook/google) and server returns 400 status code*/
"AUTH_PROVIDER_ERROR" = "This {auth_provider} account is not linked with any {platform_name} account. Please register.";
/*Subtitle for bulk download view when in new, partial or downloaded state - {count} is single video*/
"BULK_DOWNLOAD_VIDEOS_SUB_TITLE##{one}" = "{count} Video, {videos_size}MB total";
/*Subtitle for bulk download view when in new, partial or downloaded state - {count} is number of videos*/
Expand Down

0 comments on commit 4ff9007

Please sign in to comment.