Skip to content

Commit

Permalink
Fixed issue with auth code not matching
Browse files Browse the repository at this point in the history
  • Loading branch information
mzarra committed Nov 28, 2009
1 parent 640f06e commit 7a79096
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 5 deletions.
5 changes: 5 additions & 0 deletions DesktopCode/ZSyncHandler.m
Expand Up @@ -139,6 +139,7 @@ @implementation ZSyncConnectionDelegate

- (void)dealloc
{
DLog(@"%s Releasing", __PRETTY_FUNCTION__);
[_connection release], _connection = nil;
[super dealloc];
}
Expand Down Expand Up @@ -192,11 +193,15 @@ - (BOOL)connection:(BLIPConnection*)connection receivedRequest:(BLIPRequest*)req
return YES;
case zsActionAuthenticatePairing:
if ([[self pairingCode] isEqualToString:[request bodyString]]) {
DLog(@"%s passed '%@' '%@'", __PRETTY_FUNCTION__, [request bodyString], [self pairingCode]);
// TODO: Register the unique ID of this service
[[ZSyncHandler shared] registerDeviceForPairing:[request valueOfProperty:zsDeviceID]];
[response setValue:[NSString stringWithFormat:@"%i", zsActionAuthenticatePassed] ofProperty:zsAction];
[response send];
[codeController close];
[codeController release], codeController = nil;
} else {
DLog(@"%s failed '%@' '%@'", __PRETTY_FUNCTION__, [request bodyString], [self pairingCode]);
[response setValue:[NSString stringWithFormat:@"%i", zsActionAuthenticateFailed] ofProperty:zsAction];
[response send];
}
Expand Down
7 changes: 3 additions & 4 deletions DeviceCode/ZSyncTouchHandler.m
Expand Up @@ -122,11 +122,10 @@ - (void)authenticatePairing:(NSString*)code;
deviceUUID = [[NSProcessInfo processInfo] globallyUniqueString];
[[NSUserDefaults standardUserDefaults] setValue:deviceUUID forKey:zsDeviceID];
}
[dictionary setValue:code forKey:zsAuthenticationCode];

[dictionary setValue:deviceUUID forKey:zsDeviceID];

BLIPRequest *request = [BLIPRequest requestWithBody:nil properties:dictionary];

NSData *codeData = [code dataUsingEncoding:NSUTF8StringEncoding];
BLIPRequest *request = [BLIPRequest requestWithBody:codeData properties:dictionary];
[_connection sendRequest:request];
}

Expand Down
1 change: 1 addition & 0 deletions SampleDesktop/PairingCodeWindowController.m
Expand Up @@ -43,6 +43,7 @@ - (id)initWithCodeString:(NSString*)string;

- (void) dealloc
{
DLog(@"%s window released cleanly", __PRETTY_FUNCTION__);
[codeString release], codeString = nil;
[super dealloc];
}
Expand Down
1 change: 0 additions & 1 deletion SharedCode/ZSyncShared.h
Expand Up @@ -4,7 +4,6 @@

#define zsAction @"kZSyncAction"
#define zsDeviceID @"kZSyncDeviceID"
#define zsAuthenticationCode @"zsAuthenticationCode"

enum {
zsActionRequestPairing = 1123,
Expand Down

0 comments on commit 7a79096

Please sign in to comment.