Skip to content

Commit

Permalink
See #11. Almost completed Authentication implementation.
Browse files Browse the repository at this point in the history
Wrote Unit tests (See #13).
  • Loading branch information
Glavin001 committed Jul 16, 2014
1 parent 7ae4067 commit 723b048
Show file tree
Hide file tree
Showing 9 changed files with 325 additions and 909 deletions.
5 changes: 5 additions & 0 deletions Common/Nodes/SLAsset.m
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,9 @@ @implementation SLAsset
@dynamic serial;
@dynamic attributes;

+ (NSString *) type
{
return @"asset";
}

@end
22 changes: 11 additions & 11 deletions Common/Nodes/SLUser.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,16 @@
/**
*/
+ (void) registerUser:(SLUser *)theUser
withOrganization:(SLOrganization *)theOrg
withCallback:(SLSuccessCallback)theCallback;

+ (void) registerUserWithEmail:(NSString *)email
withPassword:(NSString *)password
withJobTitle:(NSString *)jobTitle
withFirstName:(NSString *)firstName
withLastName:(NSString *)lastName
withOrganization:(SLOrganization *)theOrg
withCallback:(SLSuccessCallback)theCallback;
//+ (void) registerUser:(SLUser *)theUser
// withOrganization:(SLOrganization *)theOrg
// withCallback:(SLSuccessCallback)theCallback;
//
//+ (void) registerUserWithEmail:(NSString *)email
// withPassword:(NSString *)password
// withJobTitle:(NSString *)jobTitle
// withFirstName:(NSString *)firstName
// withLastName:(NSString *)lastName
// withOrganization:(SLOrganization *)theOrg
// withCallback:(SLSuccessCallback)theCallback;

@end
68 changes: 34 additions & 34 deletions Common/Nodes/SLUser.m
Original file line number Diff line number Diff line change
Expand Up @@ -37,39 +37,39 @@ + (NSDictionary *) attributeMappings
[attrMap setValue:@"dateDue" forKey:@"date_due"];
return [NSDictionary dictionaryWithDictionary: attrMap];
}

+ (void) registerUser:(SLUser *)theUser withOrganization:(SLOrganization *)theOrg withCallback:(SLSuccessCallback)theCallback
{
/*
SLRequestCallback completionBlock = ^(NSError *error, id operation, id responseObject) {
//NSLog(@"SLRequestCallback completionBlock!");
//NSLog(@"<%@>: %@", [responseObject class], responseObject);
theCallback ? theCallback(true) : nil;
};
*/
SLRelationship *rel = [[SLRelationship alloc] initWithName:@"member" withStartNode:theUser withEndNode:theOrg];
[theUser pushWithAPIManager:[SLAPIManager sharedManager] withCallback:theCallback];
}


+ (void) registerUserWithEmail:(NSString *)email
withPassword:(NSString *)password
withJobTitle:(NSString *)jobTitle
withFirstName:(NSString *)firstName
withLastName:(NSString *)lastName
withOrganization:(SLOrganization *)theOrg
withCallback:(SLSuccessCallback)theCallback
{
NSDictionary *data = @{
@"email": email,
@"password": password,
@"job_title": jobTitle,
@"name_first": firstName,
@"name_last": lastName
};
SLUser *newUser = [SLUser createWithData:data
withRels:(NSArray *)@[]];
[[self class] registerUser:newUser withOrganization:theOrg withCallback:theCallback];
}
//
//+ (void) registerUser:(SLUser *)theUser withOrganization:(SLOrganization *)theOrg withCallback:(SLSuccessCallback)theCallback
//{
// /*
// SLRequestCallback completionBlock = ^(NSError *error, id operation, id responseObject) {
// //NSLog(@"SLRequestCallback completionBlock!");
// //NSLog(@"<%@>: %@", [responseObject class], responseObject);
// theCallback ? theCallback(true) : nil;
// };
// */
// SLRelationship *rel = [[SLRelationship alloc] initWithName:@"member" withStartNode:theUser withEndNode:theOrg];
// [theUser pushWithAPIManager:[SLAPIManager sharedManager] withCallback:theCallback];
//}
//
//
//+ (void) registerUserWithEmail:(NSString *)email
// withPassword:(NSString *)password
// withJobTitle:(NSString *)jobTitle
// withFirstName:(NSString *)firstName
// withLastName:(NSString *)lastName
// withOrganization:(SLOrganization *)theOrg
// withCallback:(SLSuccessCallback)theCallback
//{
// NSDictionary *data = @{
// @"email": email,
// @"password": password,
// @"job_title": jobTitle,
// @"name_first": firstName,
// @"name_last": lastName
// };
// SLUser *newUser = [SLUser createWithData:data
// withRels:(NSArray *)@[]];
// [[self class] registerUser:newUser withOrganization:theOrg withCallback:theCallback];
//}

@end
26 changes: 12 additions & 14 deletions Common/SLAPIManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,18 @@ typedef NS_ENUM(NSUInteger, SLHTTPMethodType)
@property (strong, nonatomic, setter=setPassword:) NSString *userPassword;
@property (strong, nonatomic, setter=setOrganization:) NSString *userOrganization;


/**
*/
+(NSString *) sha1:(NSString *)plainText;

/**
*/
+(NSString *)hmac:(NSString *)plainText withSecret:(NSString *)key;


/**
Host for creating URL.
See https://developer.apple.com/library/Mac/documentation/Cocoa/Reference/Foundation/Classes/NSURL_Class/Reference/Reference.html#jumpTo_31 for more details.
Expand All @@ -46,11 +58,6 @@ typedef NS_ENUM(NSUInteger, SLHTTPMethodType)
*/
+ (instancetype) sharedManager;

/**
*/
- (void) setBaseURL:(NSURL *)theBaseURL;

/**
Set the Email.
*/
Expand Down Expand Up @@ -86,13 +93,4 @@ typedef NS_ENUM(NSUInteger, SLHTTPMethodType)
withOrganization:(NSString *)theOrganization;


///**
// Authenticate with user credentials.
// @param theEmail The user's email.
// @param thePassword The passsword.
// */
//- (void) authenticateWithUser:(SLUser *)theUser
// withCallback:(SLSuccessCallback)theCallback DEPRECATED_ATTRIBUTE;


@end
Loading

0 comments on commit 723b048

Please sign in to comment.