- Fix check currentUser
This commit is contained in:
parent
6935f77852
commit
fef5277f7f
@ -8,7 +8,7 @@
|
|||||||
|
|
||||||
Pod::Spec.new do |s|
|
Pod::Spec.new do |s|
|
||||||
s.name = "PNObject"
|
s.name = "PNObject"
|
||||||
s.version = "0.3.1"
|
s.version = "0.3.2"
|
||||||
s.summary = "PNObject is a simple replica of the more complex ParseObject"
|
s.summary = "PNObject is a simple replica of the more complex ParseObject"
|
||||||
|
|
||||||
# This description is used to generate tags and improve search results.
|
# This description is used to generate tags and improve search results.
|
||||||
|
|||||||
@ -29,6 +29,8 @@
|
|||||||
*/
|
*/
|
||||||
- (void) logout;
|
- (void) logout;
|
||||||
|
|
||||||
|
- (BOOL) isValidUser;
|
||||||
|
|
||||||
//- (void) setPassword:(NSString * _Nonnull)password inBackGroundWithBlock:(nullable void (^)(BOOL saveStatus, id responseObject, NSError * error)) responseBlock;
|
//- (void) setPassword:(NSString * _Nonnull)password inBackGroundWithBlock:(nullable void (^)(BOOL saveStatus, id responseObject, NSError * error)) responseBlock;
|
||||||
|
|
||||||
///--------------------------------------
|
///--------------------------------------
|
||||||
|
|||||||
@ -102,6 +102,14 @@ static bool isFirstAccess = YES;
|
|||||||
[self resetObject];
|
[self resetObject];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (BOOL) isValidUser {
|
||||||
|
if(self.username && self.password && [self isValidPassword:[self password]]){
|
||||||
|
return YES;
|
||||||
|
}
|
||||||
|
|
||||||
|
return NO;
|
||||||
|
}
|
||||||
|
|
||||||
#pragma mark PNObjectSubclassing Protocol
|
#pragma mark PNObjectSubclassing Protocol
|
||||||
|
|
||||||
+ (NSDictionary *)objcetMapping {
|
+ (NSDictionary *)objcetMapping {
|
||||||
|
|||||||
@ -224,7 +224,7 @@ static bool isFirstAccess = YES;
|
|||||||
}
|
}
|
||||||
|
|
||||||
- (void) tryRefreshToken {
|
- (void) tryRefreshToken {
|
||||||
if ([PNUser currentUser]) {
|
if ([PNUser currentUser] && [[PNUser currentUser] isValidUser]) {
|
||||||
[_manager authenticateUsingOAuthWithURLString:[_currentEndPointBaseUrl stringByAppendingString:@"oauth-token"] username:[[PNUser currentUser] username] password:[[PNUser currentUser] password] scope:nil success:^(AFOAuthCredential * _Nonnull credential) {
|
[_manager authenticateUsingOAuthWithURLString:[_currentEndPointBaseUrl stringByAppendingString:@"oauth-token"] username:[[PNUser currentUser] username] password:[[PNUser currentUser] password] scope:nil success:^(AFOAuthCredential * _Nonnull credential) {
|
||||||
_currentOauthCredential = credential;
|
_currentOauthCredential = credential;
|
||||||
[_manager.requestSerializer setAuthorizationHeaderFieldWithCredential:_currentOauthCredential];
|
[_manager.requestSerializer setAuthorizationHeaderFieldWithCredential:_currentOauthCredential];
|
||||||
|
|||||||
@ -21,11 +21,10 @@
|
|||||||
// THE SOFTWARE
|
// THE SOFTWARE
|
||||||
|
|
||||||
#import <Foundation/Foundation.h>
|
#import <Foundation/Foundation.h>
|
||||||
|
#import <AFNetworking/AFNetworking.h>
|
||||||
#import "AFOAuthCredential.h"
|
#import "AFOAuthCredential.h"
|
||||||
#import "AFHTTPRequestSerializer+OAuth2.h"
|
#import "AFHTTPRequestSerializer+OAuth2.h"
|
||||||
|
|
||||||
@import AFNetworking;
|
|
||||||
|
|
||||||
NS_ASSUME_NONNULL_BEGIN
|
NS_ASSUME_NONNULL_BEGIN
|
||||||
|
|
||||||
@interface AFOAuth2Manager : AFHTTPSessionManager
|
@interface AFOAuth2Manager : AFHTTPSessionManager
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user