- ADD OAuth2 Manager
This commit is contained in:
1 parent
515d75c316
commit
31a1afdc98
65 files changed
+4110
-2732
No files matched your search
@@ -27,119 +27,118 @@ static bool isFirstAccess = YES;
|
||||
#pragma mark - Public Method
|
||||
|
||||
+ (instancetype) currentUser {
|
||||
static dispatch_once_t onceToken;
|
||||
dispatch_once(&onceToken, ^{
|
||||
isFirstAccess = NO;
|
||||
|
||||
SINGLETON = [[super allocWithZone:NULL] initForCurrentUser];
|
||||
});
|
||||
|
||||
return SINGLETON;
|
||||
static dispatch_once_t onceToken;
|
||||
dispatch_once(&onceToken, ^{
|
||||
isFirstAccess = NO;
|
||||
|
||||
SINGLETON = [[super allocWithZone:NULL] initForCurrentUser];
|
||||
});
|
||||
|
||||
return SINGLETON;
|
||||
}
|
||||
|
||||
#pragma mark - Life Cycle
|
||||
|
||||
- (instancetype)copy
|
||||
{
|
||||
return [[PNUser alloc] init];
|
||||
return [[PNUser alloc] init];
|
||||
}
|
||||
|
||||
- (instancetype)mutableCopy
|
||||
{
|
||||
return [[PNUser alloc] init];
|
||||
return [[PNUser alloc] init];
|
||||
}
|
||||
|
||||
- (instancetype) initForCurrentUser
|
||||
{
|
||||
if(SINGLETON){
|
||||
return SINGLETON;
|
||||
}
|
||||
if (isFirstAccess) {
|
||||
[self doesNotRecognizeSelector:_cmd];
|
||||
}
|
||||
|
||||
NSDictionary *savedUser = [[PNObjectModel sharedInstance] fetchObjectsWithClass:[self class]];
|
||||
|
||||
if (savedUser) {
|
||||
self = [super initWithJSON:savedUser];
|
||||
}
|
||||
else {
|
||||
self = [super init];
|
||||
}
|
||||
|
||||
if (self) {
|
||||
}
|
||||
return self;
|
||||
if(SINGLETON){
|
||||
return SINGLETON;
|
||||
}
|
||||
if (isFirstAccess) {
|
||||
[self doesNotRecognizeSelector:_cmd];
|
||||
}
|
||||
|
||||
NSDictionary *savedUser = [[PNObjectModel sharedInstance] fetchObjectsWithClass:[self class]];
|
||||
|
||||
if (savedUser) {
|
||||
self = [super initWithJSON:savedUser];
|
||||
}
|
||||
else {
|
||||
self = [super init];
|
||||
}
|
||||
|
||||
if (self) {
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void) setEmail:(NSString *)email {
|
||||
if ([email isValidEmail]) {
|
||||
_email = email;
|
||||
}
|
||||
else {
|
||||
NSLogDebug(@"insertedEmail is not valid.");
|
||||
}
|
||||
if ([email isValidEmail]) {
|
||||
_email = email;
|
||||
}
|
||||
else {
|
||||
NSLogDebug(@"insertedEmail is not valid.");
|
||||
}
|
||||
}
|
||||
|
||||
- (void) setPassword:(NSString *)password {
|
||||
if ([self isValidPassword:password]) {
|
||||
_password = password;
|
||||
}
|
||||
else {
|
||||
NSLogDebug(@"Inserted Passord is not valid.Lenght must be >= %ld",(long)[[PNObjectConfig sharedInstance] minPasswordLenght]);
|
||||
}
|
||||
if ([self isValidPassword:password]) {
|
||||
_password = password;
|
||||
}
|
||||
else {
|
||||
NSLogDebug(@"Inserted Passord is not valid.Lenght must be >= %ld",(long)[[PNObjectConfig sharedInstance] minPasswordLenght]);
|
||||
}
|
||||
}
|
||||
|
||||
- (BOOL) isValidPassword:(NSString* _Nonnull) password {
|
||||
if ([password length] >= [[PNObjectConfig sharedInstance] minPasswordLenght]) {
|
||||
return YES;
|
||||
}
|
||||
return NO;
|
||||
}
|
||||
|
||||
|
||||
- (NSString *) password {
|
||||
return @"password is not readble";
|
||||
if ([password length] >= [[PNObjectConfig sharedInstance] minPasswordLenght]) {
|
||||
return YES;
|
||||
}
|
||||
return NO;
|
||||
}
|
||||
|
||||
- (void)logout {
|
||||
[self autoRemoveLocally];
|
||||
[self resetObject];
|
||||
[self autoRemoveLocally];
|
||||
[self resetObject];
|
||||
}
|
||||
|
||||
#pragma mark PNObjectSubclassing Protocol
|
||||
|
||||
+ (NSDictionary *)objcetMapping {
|
||||
|
||||
NSDictionary *mapping = @{
|
||||
@"userId":@"id",
|
||||
@"firstName":@"firstName",
|
||||
@"lastName":@"lastName",
|
||||
@"profileImage":@"profileImage",
|
||||
@"sex":@"sex",
|
||||
@"birthDate":@"birthDate",
|
||||
@"phone":@"phone",
|
||||
@"password":@"password",
|
||||
@"hasAcceptedPrivacy":@"hasAcceptedPrivacy",
|
||||
@"hasAcceptedNewsletter":@"hasAcceptedNewsletter",
|
||||
@"hasVerifiedEmail":@"hasVerifiedEmail",
|
||||
@"emailVerifiedDate":@"emailVerifiedDate",
|
||||
@"email":@"email",
|
||||
@"username":@"username",
|
||||
@"publicProfile":@"public_profile",
|
||||
@"loginCount":@"login_count",
|
||||
@"facebookId":@"facebookId",
|
||||
@"facebookAccessToken":@"facebookAccessToken",
|
||||
};
|
||||
return mapping;
|
||||
|
||||
NSDictionary *mapping = @{
|
||||
@"userId":@"id",
|
||||
@"firstName":@"firstName",
|
||||
@"lastName":@"lastName",
|
||||
@"profileImage":@"profileImage",
|
||||
@"sex":@"sex",
|
||||
@"birthDate":@"birthDate",
|
||||
@"phone":@"phone",
|
||||
@"password":@"password",
|
||||
@"hasAcceptedPrivacy":@"hasAcceptedPrivacy",
|
||||
@"hasAcceptedNewsletter":@"hasAcceptedNewsletter",
|
||||
@"hasVerifiedEmail":@"hasVerifiedEmail",
|
||||
@"emailVerifiedDate":@"emailVerifiedDate",
|
||||
@"email":@"email",
|
||||
@"username":@"username",
|
||||
@"publicProfile":@"public_profile",
|
||||
@"loginCount":@"login_count",
|
||||
@"facebookId":@"facebookId",
|
||||
@"facebookAccessToken":@"facebookAccessToken",
|
||||
};
|
||||
return mapping;
|
||||
}
|
||||
|
||||
+ (NSString *)objectClassName {
|
||||
return @"User";
|
||||
return @"User";
|
||||
}
|
||||
|
||||
+ (NSString *) objectEndPoint {
|
||||
return @"User";
|
||||
}
|
||||
|
||||
+ (BOOL) singleInstance {
|
||||
return YES;
|
||||
return YES;
|
||||
}
|
||||
|
||||
#pragma mark -
|
||||
|
||||
Reference in new issue
Block a user