no message
This commit is contained in:
1 parent
bb38a40ea9
commit
549b27d6de
41 files changed
+7383
-3942
No files matched your search
@@ -0,0 +1,30 @@
|
||||
//
|
||||
// PNObjcPassword.h
|
||||
// Pods
|
||||
//
|
||||
// Created by Giuseppe Nucifora on 13/01/16.
|
||||
//
|
||||
//
|
||||
|
||||
#import "PNObject.h"
|
||||
|
||||
@interface PNObjcPassword : PNObject <PNObjectSubclassing>
|
||||
|
||||
+ (BOOL) validateMinimumRequirenment:(NSString * _Nullable) passString;
|
||||
|
||||
- (BOOL) isValid;
|
||||
|
||||
///--------------------------------------
|
||||
#pragma mark - PNObjcPassword Properties
|
||||
///--------------------------------------
|
||||
|
||||
/**
|
||||
* <#Description#>
|
||||
*/
|
||||
@property (nonatomic, strong, nullable) NSString *password;
|
||||
/**
|
||||
* <#Description#>
|
||||
*/
|
||||
@property (nonatomic, strong, nullable) NSString *confirmPassword;
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,81 @@
|
||||
//
|
||||
// PNObjcPassword.m
|
||||
// Pods
|
||||
//
|
||||
// Created by Giuseppe Nucifora on 13/01/16.
|
||||
//
|
||||
//
|
||||
|
||||
#import "PNObjcPassword.h"
|
||||
#import "PNUser.h"
|
||||
#import "PNObjectConstants.h"
|
||||
|
||||
@implementation PNObjcPassword
|
||||
|
||||
+ (NSString *) objectClassName {
|
||||
return @"Password";
|
||||
}
|
||||
|
||||
+(NSString *)objectEndPoint {
|
||||
return @"Password";
|
||||
}
|
||||
|
||||
+ (NSDictionary *) objcetMapping {
|
||||
NSDictionary *mapping = @{@"password":@"password",
|
||||
@"confirmPassword":@"confirmPassword",
|
||||
};
|
||||
return mapping;
|
||||
}
|
||||
|
||||
+ (BOOL)singleInstance {
|
||||
return NO;
|
||||
}
|
||||
|
||||
|
||||
|
||||
- (void) setPassword:(NSString *)password {
|
||||
if ([self validateMinimumRequirenment:password]) {
|
||||
_password = password;
|
||||
}
|
||||
else {
|
||||
NSLogDebug(@"Inserted Passord is not valid.Lenght must be >= %ld",(long)[[PNObjectConfig sharedInstance] minPasswordLenght]);
|
||||
}
|
||||
}
|
||||
|
||||
- (void) setConfirmPassword:(NSString *)confirmPassword {
|
||||
if ([self validateMinimumRequirenment:confirmPassword]) {
|
||||
if ([confirmPassword isEqualToString:_password]) {
|
||||
_confirmPassword = confirmPassword;
|
||||
}
|
||||
else {
|
||||
NSLogDebug(@"Inserted Passord is not same password.");
|
||||
}
|
||||
}
|
||||
else {
|
||||
NSLogDebug(@"Inserted Passord is not valid.Lenght must be >= %ld",(long)[[PNObjectConfig sharedInstance] minPasswordLenght]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
- (BOOL)isValid {
|
||||
if ([self validateMinimumRequirenment:_password] && [self validateMinimumRequirenment:_confirmPassword] && [_confirmPassword isEqualToString:_password]) {
|
||||
return YES;
|
||||
}
|
||||
return NO;
|
||||
}
|
||||
|
||||
- (BOOL) validateMinimumRequirenment:(NSString * _Nullable) passString {
|
||||
if ([passString length] >= [[PNObjectConfig sharedInstance] minPasswordLenght]) {
|
||||
return YES;
|
||||
}
|
||||
return NO;
|
||||
}
|
||||
|
||||
+ (BOOL) validateMinimumRequirenment:(NSString * _Nullable) passString {
|
||||
if ([passString length] >= [[PNObjectConfig sharedInstance] minPasswordLenght]) {
|
||||
return YES;
|
||||
}
|
||||
return NO;
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -7,6 +7,7 @@
|
||||
//
|
||||
|
||||
#import "PNObject.h"
|
||||
#import "PNObjcPassword.h"
|
||||
|
||||
@interface PNUser : PNObject
|
||||
|
||||
@@ -33,15 +34,6 @@
|
||||
*/
|
||||
+ (BOOL) isValidPassword:(NSString* _Nonnull) password;
|
||||
|
||||
/**
|
||||
* <#Description#>
|
||||
*
|
||||
* @param password <#password description#>
|
||||
*
|
||||
* @return <#return value description#>
|
||||
*/
|
||||
- (BOOL) isValidPassword:(NSString* _Nonnull) password;
|
||||
|
||||
/**
|
||||
* <#Description#>
|
||||
*/
|
||||
@@ -159,11 +151,7 @@
|
||||
/**
|
||||
* <#Description#>
|
||||
*/
|
||||
@property (nonatomic, strong, nullable) NSString * password;
|
||||
/**
|
||||
* <#Description#>
|
||||
*/
|
||||
@property (nonatomic, strong, nullable) NSString * confirmPassword;
|
||||
@property (nonatomic, strong, nullable) PNObjcPassword * password;
|
||||
/**
|
||||
* <#Description#>
|
||||
*/
|
||||
@@ -184,6 +172,9 @@
|
||||
* <#Description#>
|
||||
*/
|
||||
@property (nonatomic, strong, nullable) NSString * facebookAccessToken;
|
||||
|
||||
/**
|
||||
* <#Description#>
|
||||
*/
|
||||
@property (nonatomic, strong, nullable) NSDate * registeredAt;
|
||||
|
||||
@end
|
||||
@@ -15,6 +15,7 @@
|
||||
#import <FBSDKCoreKit/FBSDKCoreKit.h>
|
||||
#import <FBSDKLoginKit/FBSDKLoginKit.h>
|
||||
#import <FBSDKShareKit/FBSDKShareKit.h>
|
||||
#import "PNObjcPassword.h"
|
||||
|
||||
|
||||
@interface PNUser() <PNObjectSubclassing>
|
||||
@@ -98,56 +99,23 @@ static bool isFirstAccess = YES;
|
||||
}
|
||||
}
|
||||
|
||||
- (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]);
|
||||
}
|
||||
}
|
||||
|
||||
- (void) setConfirmPassword:(NSString *)confirmPassword {
|
||||
if ([self isValidPassword:confirmPassword]) {
|
||||
if ([confirmPassword isEqualToString:_password]) {
|
||||
_confirmPassword = confirmPassword;
|
||||
}
|
||||
else {
|
||||
NSLogDebug(@"Inserted Passord is not same 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;
|
||||
}
|
||||
|
||||
+ (BOOL) isValidPassword:(NSString* _Nonnull) password {
|
||||
if ([password length] >= [[PNObjectConfig sharedInstance] minPasswordLenght]) {
|
||||
return YES;
|
||||
}
|
||||
return NO;
|
||||
}
|
||||
|
||||
- (void)logout {
|
||||
[self autoRemoveLocally];
|
||||
[self resetObject];
|
||||
}
|
||||
|
||||
- (BOOL) hasValidEmailAndPasswordData {
|
||||
if(self.email && [self.email isValidEmail] && self.password && [self isValidPassword:[self password]]){
|
||||
if(self.email && [self.email isValidEmail] && self.password && [self.password isValid]){
|
||||
return YES;
|
||||
}
|
||||
|
||||
return NO;
|
||||
}
|
||||
|
||||
+ (BOOL) isValidPassword:(NSString* _Nonnull) password {
|
||||
return [PNObjcPassword validateMinimumRequirenment:password];
|
||||
}
|
||||
|
||||
- (void) autoLogin {
|
||||
[self autoLoginWithBlockSuccess:nil failure:nil];
|
||||
}
|
||||
@@ -300,10 +268,13 @@ static bool isFirstAccess = YES;
|
||||
|
||||
[[PNObjectConfig sharedInstance] refreshTokenForUserWithEmail:email password:password withBlockSuccess:^(BOOL refreshSuccess) {
|
||||
if (refreshSuccess) {
|
||||
PNObjcPassword *objectPassword = [PNObjcPassword new];
|
||||
[objectPassword setPassword:password];
|
||||
[objectPassword setConfirmPassword:password];
|
||||
|
||||
[self setAuthenticated:YES];
|
||||
[self setEmail:email];
|
||||
[self setPassword:password];
|
||||
[self setConfirmPassword:password];
|
||||
[self setPassword:objectPassword];
|
||||
[self saveLocally];
|
||||
|
||||
if (success) {
|
||||
@@ -331,8 +302,7 @@ static bool isFirstAccess = YES;
|
||||
@"sex":@"sex",
|
||||
@"birthDate":@"birthDate",
|
||||
@"phone":@"phone",
|
||||
@"password":@"plainPassword[first]",
|
||||
@"confirmPassword":@"plainPassword[second]",
|
||||
@"password":@{@"key":@"password",@"type":@"PNObjcPassword"},
|
||||
@"hasAcceptedPrivacy":@"hasAcceptedPrivacy",
|
||||
@"hasAcceptedNewsletter":@"hasAcceptedNewsletter",
|
||||
@"hasVerifiedEmail":@"hasVerifiedEmail",
|
||||
|
||||
Reference in new issue
Block a user