Merge branch 'develop' into 'master'
- Fix check currentUser See merge request !18
This commit is contained in:
commit
ea6cb89248
@ -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 {
|
||||||
|
|||||||
@ -1,10 +1,10 @@
|
|||||||
//
|
//
|
||||||
// PNObjectConfig.m
|
// PNObjectConfig.m
|
||||||
// Pods
|
// Pods
|
||||||
//
|
//
|
||||||
// Created by Giuseppe Nucifora on 08/01/16.
|
// Created by Giuseppe Nucifora on 08/01/16.
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
|
|
||||||
#import "PNObjectConfig.h"
|
#import "PNObjectConfig.h"
|
||||||
#import "PNObjectConstants.h"
|
#import "PNObjectConstants.h"
|
||||||
@ -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];
|
||||||
|
|||||||
@ -1,38 +1,37 @@
|
|||||||
// AFOAuth2Manager.h
|
// AFOAuth2Manager.h
|
||||||
//
|
//
|
||||||
// Copyright (c) 2012-2014 AFNetworking (http://afnetworking.com)
|
// Copyright (c) 2012-2014 AFNetworking (http://afnetworking.com)
|
||||||
//
|
//
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
// of this software and associated documentation files (the "Software"), to deal
|
// of this software and associated documentation files (the "Software"), to deal
|
||||||
// in the Software without restriction, including without limitation the rights
|
// in the Software without restriction, including without limitation the rights
|
||||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
// copies of the Software, and to permit persons to whom the Software is
|
// copies of the Software, and to permit persons to whom the Software is
|
||||||
// furnished to do so, subject to the following conditions:
|
// furnished to do so, subject to the following conditions:
|
||||||
//
|
//
|
||||||
// The above copyright notice and this permission notice shall be included in
|
// The above copyright notice and this permission notice shall be included in
|
||||||
// all copies or substantial portions of the Software.
|
// all copies or substantial portions of the Software.
|
||||||
//
|
//
|
||||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
// 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
|
||||||
|
|
||||||
///------------------------------------------
|
///------------------------------------------
|
||||||
/// @name Accessing OAuth 2 Client Properties
|
/// @name Accessing OAuth 2 Client Properties
|
||||||
///------------------------------------------
|
///------------------------------------------
|
||||||
|
|
||||||
/**
|
/**
|
||||||
The service provider identifier used to store and retrieve OAuth credentials by `AFOAuthCredential`. Equivalent to the hostname of the client `baseURL`.
|
The service provider identifier used to store and retrieve OAuth credentials by `AFOAuthCredential`. Equivalent to the hostname of the client `baseURL`.
|
||||||
@ -49,9 +48,9 @@ NS_ASSUME_NONNULL_BEGIN
|
|||||||
*/
|
*/
|
||||||
@property (nonatomic, assign) BOOL useHTTPBasicAuthentication;
|
@property (nonatomic, assign) BOOL useHTTPBasicAuthentication;
|
||||||
|
|
||||||
///------------------------------------------------
|
///------------------------------------------------
|
||||||
/// @name Creating and Initializing OAuth 2 Managers
|
/// @name Creating and Initializing OAuth 2 Managers
|
||||||
///------------------------------------------------
|
///------------------------------------------------
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Creates and initializes an `AFOAuth2Manager` object with the specified base URL, client identifier, and secret.
|
Creates and initializes an `AFOAuth2Manager` object with the specified base URL, client identifier, and secret.
|
||||||
@ -89,9 +88,9 @@ NS_ASSUME_NONNULL_BEGIN
|
|||||||
clientID:(NSString *)clientID
|
clientID:(NSString *)clientID
|
||||||
secret:(NSString *)secret;
|
secret:(NSString *)secret;
|
||||||
|
|
||||||
///---------------------
|
///---------------------
|
||||||
/// @name Authenticating
|
/// @name Authenticating
|
||||||
///---------------------
|
///---------------------
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Creates and enqueues an `NSURLSessionTask` to authenticate against the server using a specified username and password, with a designated scope.
|
Creates and enqueues an `NSURLSessionTask` to authenticate against the server using a specified username and password, with a designated scope.
|
||||||
@ -164,9 +163,9 @@ NS_ASSUME_NONNULL_BEGIN
|
|||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
///----------------
|
///----------------
|
||||||
/// @name Constants
|
/// @name Constants
|
||||||
///----------------
|
///----------------
|
||||||
|
|
||||||
/**
|
/**
|
||||||
## Error Domains
|
## Error Domains
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user