- Add isAuthenticated method

- Fix vari
This commit is contained in:
giuseppenuc committed 2016-02-12 10:39:47 +01:00
1 parent 963a3b6e2f
commit fab098e9ab
5 files changed
+38 -26

No files matched your search

+1 -1
View File
@@ -96,7 +96,7 @@
*
* @return <#return value description#>
*/
- (BOOL) autenticated;
- (BOOL) isAuthenticated;
//- (void) setPassword:(NSString * _Nonnull)password inBackGroundWithBlock:(nullable void (^)(BOOL saveStatus, id responseObject, NSError * error)) responseBlock;
+14 -2
View File
@@ -19,6 +19,8 @@
@interface PNUser() <PNObjectSubclassing>
@property (nonatomic) BOOL authenticated;
@end
@implementation PNUser
@@ -79,6 +81,10 @@ static bool isFirstAccess = YES;
}
if (SINGLETON) {
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
[self autoLogin];
});
}
return SINGLETON;
}
@@ -293,10 +299,15 @@ static bool isFirstAccess = YES;
failure:(nullable void (^)(NSError * _Nonnull error))failure {
[[PNObjectConfig sharedInstance] refreshTokenForUserWithEmail:email password:password withBlockSuccess:^(BOOL refreshSuccess) {
if (refreshSuccess) {
[self setAuthenticated:YES];
[self setEmail:email];
[self setPassword:password];
[self setConfirmPassword:password];
[self saveLocally];
if (success) {
success([PNUser currentUser]);
success(self);
}
}
} failure:failure];
@@ -330,6 +341,7 @@ static bool isFirstAccess = YES;
@"facebookAccessToken":@"facebookAccessToken",
@"isFacebookUser":@"isFacebookUser",
@"registeredAt":@"registeredAt",
@"authenticated":@"authenticated"
};
return mapping;
}
+1 -8
View File
@@ -293,14 +293,7 @@ static bool isFirstAccess = YES;
[AFOAuthCredential storeCredential:_currentOauthCredential withIdentifier:PNObjectServiceCredentialIdentifier];
[_manager.requestSerializer setAuthorizationHeaderFieldWithCredential:_currentOauthCredential];
PNUser *user = [PNUser currentUser];
[user setEmail:email];
[user setPassword:password];
[user setConfirmPassword:password];
[user saveLocally];
if (success) {
success(YES);
}