From 6932438b3d28f757a8b6e951e35f0a7944ae202c Mon Sep 17 00:00:00 2001 From: Manuel Trezza <5673677+mtrezza@users.noreply.github.com> Date: Wed, 22 Feb 2023 15:44:20 +0100 Subject: [PATCH 1/3] Update PFUserAuthenticationController.m --- .../Controller/PFUserAuthenticationController.m | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/Parse/Parse/Internal/User/AuthenticationProviders/Controller/PFUserAuthenticationController.m b/Parse/Parse/Internal/User/AuthenticationProviders/Controller/PFUserAuthenticationController.m index 87438b76c..2ac630632 100644 --- a/Parse/Parse/Internal/User/AuthenticationProviders/Controller/PFUserAuthenticationController.m +++ b/Parse/Parse/Internal/User/AuthenticationProviders/Controller/PFUserAuthenticationController.m @@ -55,8 +55,13 @@ - (void)registerAuthenticationDelegate:(id)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; }); From 80e6e8e97215635a3492ae5da30eccd0528351c4 Mon Sep 17 00:00:00 2001 From: Manuel Trezza <5673677+mtrezza@users.noreply.github.com> Date: Wed, 22 Feb 2023 15:59:00 +0100 Subject: [PATCH 2/3] add PFUser.unregisterAuthType --- Parse/Parse/Source/PFUser.h | 13 ++++++++++++- Parse/Parse/Source/PFUser.m | 4 ++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/Parse/Parse/Source/PFUser.h b/Parse/Parse/Source/PFUser.h index 051d6671b..1f042d4d7 100644 --- a/Parse/Parse/Source/PFUser.h +++ b/Parse/Parse/Source/PFUser.h @@ -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 @@ -293,6 +294,16 @@ typedef void(^PFUserLogoutResultBlock)(NSError *_Nullable error); */ + (void)registerAuthenticationDelegate:(id)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)unregisterAuthType:(NSString *)authType; + /** Logs in a user with third party authentication credentials. diff --git a/Parse/Parse/Source/PFUser.m b/Parse/Parse/Source/PFUser.m index 5d554db2c..c113141ff 100644 --- a/Parse/Parse/Source/PFUser.m +++ b/Parse/Parse/Source/PFUser.m @@ -848,6 +848,10 @@ + (void)registerAuthenticationDelegate:(id)delegat [[self authenticationController] registerAuthenticationDelegate:delegate forAuthType:authType]; } ++ (void)unregisterAuthType:(NSString *)authType { + [[self authenticationController] unregisterAuthenticationDelegateForAuthType:authType]; +} + #pragma mark Log In + (BFTask<__kindof PFUser *> *)logInWithAuthTypeInBackground:(NSString *)authType From e906ed4c72f45246185e999959bda861c71e5b46 Mon Sep 17 00:00:00 2001 From: Manuel Trezza <5673677+mtrezza@users.noreply.github.com> Date: Wed, 22 Feb 2023 16:01:15 +0100 Subject: [PATCH 3/3] fix naming --- Parse/Parse/Source/PFUser.h | 2 +- Parse/Parse/Source/PFUser.m | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Parse/Parse/Source/PFUser.h b/Parse/Parse/Source/PFUser.h index 1f042d4d7..86390f31c 100644 --- a/Parse/Parse/Source/PFUser.h +++ b/Parse/Parse/Source/PFUser.h @@ -302,7 +302,7 @@ typedef void(^PFUserLogoutResultBlock)(NSError *_Nullable error); @param authType The name of the type of third party authentication source. */ -+ (void)unregisterAuthType:(NSString *)authType; ++ (void)unregisterAuthenticationDelegateForAuthType:(NSString *)authType; /** Logs in a user with third party authentication credentials. diff --git a/Parse/Parse/Source/PFUser.m b/Parse/Parse/Source/PFUser.m index c113141ff..9de923bea 100644 --- a/Parse/Parse/Source/PFUser.m +++ b/Parse/Parse/Source/PFUser.m @@ -848,7 +848,7 @@ + (void)registerAuthenticationDelegate:(id)delegat [[self authenticationController] registerAuthenticationDelegate:delegate forAuthType:authType]; } -+ (void)unregisterAuthType:(NSString *)authType { ++ (void)unregisterAuthenticationDelegateForAuthType:(NSString *)authType { [[self authenticationController] unregisterAuthenticationDelegateForAuthType:authType]; }