- Fi vari
This commit is contained in:
1 parent
bc854abc37
commit
a818aafa0c
17 files changed
+995
-951
No files matched your search
@@ -272,6 +272,8 @@ static bool isFirstAccess = YES;
|
||||
|
||||
[[PNObjectConfig sharedInstance] refreshTokenForUserWithEmail:email password:password withBlockSuccess:^(BOOL refreshSuccess) {
|
||||
if (refreshSuccess) {
|
||||
|
||||
|
||||
PNUser *user = [[self class] new];
|
||||
|
||||
PNObjcPassword *objectPassword = [PNObjcPassword new];
|
||||
@@ -353,7 +355,7 @@ static bool isFirstAccess = YES;
|
||||
}
|
||||
|
||||
+ (NSString *)objectClassName {
|
||||
return @"User";
|
||||
return @"PNUser";
|
||||
}
|
||||
|
||||
+ (NSString *) objectEndPoint {
|
||||
|
||||
@@ -41,7 +41,7 @@ extern NSString* _Nonnull const Client_Secret;
|
||||
/**
|
||||
* Oauth is NO by default
|
||||
*
|
||||
* @param clientIdsForEnvironments
|
||||
* @param endpointUrlsForEnvironments
|
||||
* For example,
|
||||
* @{ PNObjectConfigDevelopment : @"https://development.it/api/v1",
|
||||
* PNObjectConfigEnvStage : @"ttps://stage.it/api/v1",
|
||||
@@ -52,10 +52,25 @@ extern NSString* _Nonnull const Client_Secret;
|
||||
*/
|
||||
+ (instancetype _Nonnull) initSharedInstanceForEnvironments:(NSDictionary * _Nonnull) endpointUrlsForEnvironments;
|
||||
|
||||
/**
|
||||
* <#Description#>
|
||||
*
|
||||
* @param endpointUrlsForEnvironments
|
||||
* For example,
|
||||
* @{ PNObjectConfigDevelopment : @"https://development.it/api/v1",
|
||||
* PNObjectConfigEnvStage : @"ttps://stage.it/api/v1",
|
||||
* PNObjectConfigEnvProduction : @"ttps://production.it/api/v1"
|
||||
* }
|
||||
* @param userSubClass <#userSubClass description#>
|
||||
*
|
||||
* @return <#return value description#>
|
||||
*/
|
||||
+ (instancetype _Nonnull) initSharedInstanceForEnvironments:(NSDictionary * _Nonnull) endpointUrlsForEnvironments andUserSubclass:(Class _Nonnull) userSubClass;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @param clientIdsForEnvironments
|
||||
* @param endpointUrlsForEnvironments
|
||||
* For example,
|
||||
* @{ PNObjectConfigDevelopment : @"https://development.it/api/v1",
|
||||
* PNObjectConfigEnvStage : @"ttps://stage.it/api/v1",
|
||||
@@ -67,6 +82,21 @@ extern NSString* _Nonnull const Client_Secret;
|
||||
*/
|
||||
+ (instancetype _Nonnull) initSharedInstanceForEnvironments:(NSDictionary * _Nonnull) endpointUrlsForEnvironments withOauth:(BOOL) oauthEnabled;
|
||||
|
||||
/**
|
||||
* <#Description#>
|
||||
*
|
||||
* @param endpointUrlsForEnvironments
|
||||
* For example,
|
||||
* @{ PNObjectConfigDevelopment : @"https://development.it/api/v1",
|
||||
* PNObjectConfigEnvStage : @"ttps://stage.it/api/v1",
|
||||
* PNObjectConfigEnvProduction : @"ttps://production.it/api/v1"
|
||||
* }
|
||||
* @param userSubClass <#userSubClass description#>
|
||||
* @param oauthEnabled <#oauthEnabled description#>
|
||||
*
|
||||
* @return <#return value description#>
|
||||
*/
|
||||
+ (instancetype _Nonnull) initSharedInstanceForEnvironments:(NSDictionary * _Nonnull) endpointUrlsForEnvironments userSubclass:(Class _Nonnull) userSubClass withOauth:(BOOL) oauthEnabled;
|
||||
/**
|
||||
* <#Description#>
|
||||
*
|
||||
|
||||
@@ -47,6 +47,7 @@ NSString* const Client_Secret = @"client_secret";
|
||||
@property (nonatomic, strong) NSString *currentOAuthClientID;
|
||||
@property (nonatomic, strong) NSString *currentOAuthClientSecret;
|
||||
//@property (nonatomic, strong) NSMutableDictionary *environments;
|
||||
@property (nonatomic) Class userSubClass;
|
||||
|
||||
@end
|
||||
|
||||
@@ -74,14 +75,24 @@ static bool isFirstAccess = YES;
|
||||
#pragma mark - Life Cycle
|
||||
|
||||
+ (instancetype) initSharedInstanceForEnvironments:(NSDictionary *) endpointUrlsForEnvironments {
|
||||
return [self initSharedInstanceForEnvironments:endpointUrlsForEnvironments withOauth:NO];
|
||||
return [self initSharedInstanceForEnvironments:endpointUrlsForEnvironments userSubclass:[PNUser class] withOauth:NO];
|
||||
}
|
||||
|
||||
+ (instancetype) initSharedInstanceForEnvironments:(NSDictionary *)endpointUrlsForEnvironments andUserSubclass:(Class)userSubClass {
|
||||
return [self initSharedInstanceForEnvironments:endpointUrlsForEnvironments userSubclass:userSubClass withOauth:NO];
|
||||
}
|
||||
|
||||
|
||||
+ (instancetype) initSharedInstanceForEnvironments:(NSDictionary *) endpointUrlsForEnvironments withOauth:(BOOL) oauthEnabled {
|
||||
return [self initSharedInstanceForEnvironments:endpointUrlsForEnvironments userSubclass:[PNUser class] withOauth:oauthEnabled];
|
||||
}
|
||||
|
||||
+ (instancetype _Nonnull) initSharedInstanceForEnvironments:(NSDictionary * _Nonnull) endpointUrlsForEnvironments userSubclass:(Class _Nonnull) userSubClass withOauth:(BOOL) oauthEnabled {
|
||||
SINGLETON = [self sharedInstance];
|
||||
|
||||
if (SINGLETON) {
|
||||
SINGLETON.oauthEnabled = oauthEnabled;
|
||||
SINGLETON.userSubClass = userSubClass;
|
||||
for (NSString *key in [endpointUrlsForEnvironments allKeys]) {
|
||||
|
||||
NSURL * endpointUrl = [NSURL URLWithString:[endpointUrlsForEnvironments objectForKey:key]];
|
||||
@@ -232,7 +243,9 @@ static bool isFirstAccess = YES;
|
||||
}
|
||||
|
||||
- (void) refreshToken {
|
||||
if([PNUser currentUser] && [[PNUser currentUser] hasValidEmailAndPasswordData]) {
|
||||
|
||||
|
||||
if([SINGLETON.userSubClass currentUser] && [[SINGLETON.userSubClass currentUser] hasValidEmailAndPasswordData]) {
|
||||
[self refreshTokenForUser];
|
||||
}
|
||||
else {
|
||||
@@ -248,7 +261,7 @@ static bool isFirstAccess = YES;
|
||||
- (void) refreshTokenForUserWithBlockSuccess:(nullable void (^)(BOOL refreshSuccess))success
|
||||
failure:(nullable void (^)(NSError * _Nonnull error))failure {
|
||||
|
||||
if([PNUser currentUser] && [[PNUser currentUser] hasValidEmailAndPasswordData]) {
|
||||
if([SINGLETON.userSubClass currentUser] && [[SINGLETON.userSubClass currentUser] hasValidEmailAndPasswordData]) {
|
||||
[_manager authenticateUsingOAuthWithURLString:[_currentEndPointBaseUrl stringByAppendingString:@"oauth-token"] username:[[PNUser currentUser] email] password:[[[PNUser currentUser] password] password] scope:nil success:^(AFOAuthCredential * _Nonnull credential) {
|
||||
_currentOauthCredential = credential;
|
||||
|
||||
|
||||
Reference in new issue
Block a user