Skip to content

Commit

Permalink
Revert "Removed long-deprecated facebook/persona auth API in CBLRepli…
Browse files Browse the repository at this point in the history
…cation"

This reverts commit 23c0dc2.
(See #833)
  • Loading branch information
snej committed Sep 14, 2015
1 parent 284f280 commit 7d01d2a
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 1 deletion.
11 changes: 11 additions & 0 deletions Source/API/CBLReplication.h
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,17 @@ typedef NS_ENUM(unsigned, CBLReplicationStatus) {

- (instancetype) init NS_UNAVAILABLE;

#ifdef CBL_DEPRECATED
@property (nonatomic, copy) NSString* facebookEmailAddress
__attribute__((deprecated("set authenticator property instead")));
- (BOOL) registerFacebookToken: (NSString*)token forEmailAddress: (NSString*)email
__attribute__((deprecated("set authenticator property instead")));
- (BOOL) registerPersonaAssertion: (NSString*)assertion
__attribute__((deprecated("set authenticator property instead")));
@property (nonatomic, copy) NSString* personaEmailAddress
__attribute__((deprecated("set authenticator property instead")));
#endif

@end


Expand Down
38 changes: 37 additions & 1 deletion Source/API/CBLReplication.m
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
#import "CBLDatabase+Internal.h"
#import "CBLManager+Internal.h"
#import "CBL_Server.h"
#import "CBLPersonaAuthorizer.h"
#import "CBLFacebookAuthorizer.h"
#import "CBLCookieStorage.h"
#import "MYBlockUtils.h"
#import "MYURLUtils.h"
Expand Down Expand Up @@ -156,11 +158,41 @@ - (void) setCredential:(NSURLCredential *)cred {
}


#ifdef CBL_DEPRECATED

@synthesize facebookEmailAddress=_facebookEmailAddress;

- (BOOL) registerFacebookToken: (NSString*)token forEmailAddress: (NSString*)email {
if (![CBLFacebookAuthorizer registerToken: token forEmailAddress: email forSite: self.remoteURL])
return false;
self.facebookEmailAddress = email;
[self restart];
return true;
}
#endif


- (NSURL*) personaOrigin {
return self.remoteURL.my_baseURL;
}


#ifdef CBL_DEPRECATED
@synthesize personaEmailAddress=_personaEmailAddress;

- (BOOL) registerPersonaAssertion: (NSString*)assertion {
NSString* email = [CBLPersonaAuthorizer registerAssertion: assertion];
if (!email) {
Warn(@"Invalid Persona assertion: %@", assertion);
return false;
}
self.personaEmailAddress = email;
[self restart];
return true;
}
#endif


- (void) setCookieNamed: (NSString*)name
withValue: (NSString*)value
path: (NSString*)path
Expand Down Expand Up @@ -225,9 +257,13 @@ - (NSDictionary*) properties {
NSMutableDictionary* authDict = nil;
if (_authenticator) {
remoteURL = remoteURL.my_URLByRemovingUser;
} else if (_OAuth) {
} else if (_OAuth || _facebookEmailAddress || _personaEmailAddress) {
remoteURL = remoteURL.my_URLByRemovingUser;
authDict = $mdict({@"oauth", _OAuth});
if (_facebookEmailAddress)
authDict[@"facebook"] = @{@"email": _facebookEmailAddress};
if (_personaEmailAddress)
authDict[@"persona"] = @{@"email": _personaEmailAddress};
}
NSDictionary* remote = $dict({@"url", remoteURL.absoluteString},
{@"headers", _headers},
Expand Down

0 comments on commit 7d01d2a

Please sign in to comment.