Skip to content

Commit

Permalink
Merge pull request #72 from nemesis/login_refresh_patch
Browse files Browse the repository at this point in the history
Fix plain login refresh response serializing
  • Loading branch information
nemesis authored Oct 19, 2016
2 parents 1dfb540 + 54c8083 commit 6907a66
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 10 deletions.
2 changes: 1 addition & 1 deletion Classes/API/SEAPIRequestManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,7 @@ typedef NS_ENUM(NSUInteger, SEAPIRequestManagerSSLPinningMode) {
@see https://docs.saltedge.com/reference/#logins-refresh
*/
- (void)refreshLoginWithSecret:(NSString*)loginSecret
success:(void (^)(NSDictionary* responseObject))success
success:(void (^)(SELogin* login))success
failure:(SEAPIRequestFailureBlock)failure
delegate:(id<SELoginFetchingDelegate>)delegate;

Expand Down
9 changes: 4 additions & 5 deletions Classes/API/SEAPIRequestManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -473,7 +473,7 @@ - (void)reconnectOAuthLoginWithSecret:(NSString*)loginSecret
}

- (void)refreshLoginWithSecret:(NSString*)loginSecret
success:(void (^)(NSDictionary* responseObject))success
success:(void (^)(SELogin* login))success
failure:(SEAPIRequestFailureBlock)failure
delegate:(id<SELoginFetchingDelegate>)delegate
{
Expand All @@ -486,10 +486,9 @@ - (void)refreshLoginWithSecret:(NSString*)loginSecret
parameters:nil
headers:[self sessionHeadersWithLoginSecret:loginSecret]
success:^(NSDictionary* responseObject) {
if (success) {
success(responseObject);
}
if (![responseObject[kDataKey][kRefreshedKey] boolValue]) { return; }
if (!success) { return; }
SELogin* fetchedLogin = [SELogin objectFromDictionary:responseObject[kDataKey]];
success(fetchedLogin);
self.loginFetchingDelegate = delegate;
if ([self isLoginFetchingDelegateSuitableForDelegation]) {
[self pollLoginWithSecret:loginSecret];
Expand Down
6 changes: 2 additions & 4 deletions Salt Edge API Demo/Controllers/AccountsTVC.m
Original file line number Diff line number Diff line change
Expand Up @@ -121,10 +121,8 @@ - (void)refreshCurrentLoginViaAPI
SEAPIRequestManager* manager = [SEAPIRequestManager manager];
if (!self.loginsProvider.isOAuth) {
[manager refreshLoginWithSecret:self.login.secret
success:^(NSDictionary* dictionary) {
if (![dictionary[kDataKey][kRefreshedKey] boolValue]) {
[SVProgressHUD showErrorWithStatus:@"Could not refresh login."];
}
success:^(SELogin* login) {
// Nothing here. Need to wait for SELoginFetchingDelegate callbacks
}
failure:^(SEError* error) {
[SVProgressHUD showErrorWithStatus:error.errorMessage];
Expand Down

0 comments on commit 6907a66

Please sign in to comment.