File tree Expand file tree Collapse file tree 3 files changed +23
-3
lines changed
Internal/User/AuthenticationProviders/Controller Expand file tree Collapse file tree 3 files changed +23
-3
lines changed Original file line number Diff line number Diff line change @@ -55,8 +55,13 @@ - (void)registerAuthenticationDelegate:(id<PFUserAuthenticationDelegate>)delegat
5555 forAuthType : (NSString *)authType {
5656 PFParameterAssert (delegate, @" Authentication delegate can't be `nil`." );
5757 PFParameterAssert (authType, @" `authType` can't be `nil`." );
58- PFParameterAssert (![self authenticationDelegateForAuthType: authType],
59- @" Authentication delegate already registered for authType `%@ `." , authType);
58+
59+ // If auth delete is already registered then unregister it gracefully
60+ if ([self authenticationDelegateForAuthType: authType]) {
61+ NSLog (@" unregistering existing deletegate to gracefully register new delegate for authType `%@ `." , authType);
62+ [self unregisterAuthenticationDelegateForAuthType: authType];
63+ }
64+
6065 dispatch_sync (_dataAccessQueue, ^{
6166 self->_authenticationDelegates [authType] = delegate;
6267 });
Original file line number Diff line number Diff line change @@ -283,7 +283,8 @@ typedef void(^PFUserLogoutResultBlock)(NSError *_Nullable error);
283283// /--------------------------------------
284284
285285/* *
286- Registers a third party authentication delegate.
286+ Registers a third party authentication delegate. If a delegate is already registered for the authType then
287+ it is replaced by the new delegate.
287288
288289 @note This method shouldn't be invoked directly unless developing a third party authentication library.
289290 @see PFUserAuthenticationDelegate
@@ -293,6 +294,16 @@ typedef void(^PFUserLogoutResultBlock)(NSError *_Nullable error);
293294 */
294295+ (void )registerAuthenticationDelegate : (id <PFUserAuthenticationDelegate>)delegate forAuthType : (NSString *)authType ;
295296
297+ /* *
298+ Unregisters a third party authentication delegate. If no delegate is registered, this fails gracefully.
299+
300+ @note This method shouldn't be invoked directly unless developing a third party authentication library.
301+ @see PFUserAuthenticationDelegate
302+
303+ @param authType The name of the type of third party authentication source.
304+ */
305+ + (void )unregisterAuthenticationDelegateForAuthType : (NSString *)authType ;
306+
296307/* *
297308 Logs in a user with third party authentication credentials.
298309
Original file line number Diff line number Diff line change @@ -848,6 +848,10 @@ + (void)registerAuthenticationDelegate:(id<PFUserAuthenticationDelegate>)delegat
848848 [[self authenticationController ] registerAuthenticationDelegate: delegate forAuthType: authType];
849849}
850850
851+ + (void )unregisterAuthenticationDelegateForAuthType : (NSString *)authType {
852+ [[self authenticationController ] unregisterAuthenticationDelegateForAuthType: authType];
853+ }
854+
851855#pragma mark Log In
852856
853857+ (BFTask<__kindof PFUser *> *)logInWithAuthTypeInBackground : (NSString *)authType
You can’t perform that action at this time.
0 commit comments