Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,13 @@ - (void)registerAuthenticationDelegate:(id<PFUserAuthenticationDelegate>)delegat
forAuthType:(NSString *)authType {
PFParameterAssert(delegate, @"Authentication delegate can't be `nil`.");
PFParameterAssert(authType, @"`authType` can't be `nil`.");
PFParameterAssert(![self authenticationDelegateForAuthType:authType],
@"Authentication delegate already registered for authType `%@`.", authType);

// If auth delete is already registered then unregister it gracefully
if ([self authenticationDelegateForAuthType:authType]) {
NSLog(@"unregistering existing deletegate to gracefully register new delegate for authType `%@`.", authType);
[self unregisterAuthenticationDelegateForAuthType:authType];
}

dispatch_sync(_dataAccessQueue, ^{
self->_authenticationDelegates[authType] = delegate;
});
Expand Down
13 changes: 12 additions & 1 deletion Parse/Parse/Source/PFUser.h
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,8 @@ typedef void(^PFUserLogoutResultBlock)(NSError *_Nullable error);
///--------------------------------------

/**
Registers a third party authentication delegate.
Registers a third party authentication delegate. If a delegate is already registered for the authType then
it is replaced by the new delegate.

@note This method shouldn't be invoked directly unless developing a third party authentication library.
@see PFUserAuthenticationDelegate
Expand All @@ -293,6 +294,16 @@ typedef void(^PFUserLogoutResultBlock)(NSError *_Nullable error);
*/
+ (void)registerAuthenticationDelegate:(id<PFUserAuthenticationDelegate>)delegate forAuthType:(NSString *)authType;

/**
Unregisters a third party authentication delegate. If no delegate is registered, this fails gracefully.

@note This method shouldn't be invoked directly unless developing a third party authentication library.
@see PFUserAuthenticationDelegate

@param authType The name of the type of third party authentication source.
*/
+ (void)unregisterAuthenticationDelegateForAuthType:(NSString *)authType;

/**
Logs in a user with third party authentication credentials.

Expand Down
4 changes: 4 additions & 0 deletions Parse/Parse/Source/PFUser.m
Original file line number Diff line number Diff line change
Expand Up @@ -848,6 +848,10 @@ + (void)registerAuthenticationDelegate:(id<PFUserAuthenticationDelegate>)delegat
[[self authenticationController] registerAuthenticationDelegate:delegate forAuthType:authType];
}

+ (void)unregisterAuthenticationDelegateForAuthType:(NSString *)authType {
[[self authenticationController] unregisterAuthenticationDelegateForAuthType:authType];
}

#pragma mark Log In

+ (BFTask<__kindof PFUser *> *)logInWithAuthTypeInBackground:(NSString *)authType
Expand Down