File tree 3 files changed +23
-3
lines changed
Internal/User/AuthenticationProviders/Controller 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
55
55
forAuthType : (NSString *)authType {
56
56
PFParameterAssert (delegate, @" Authentication delegate can't be `nil`." );
57
57
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
+
60
65
dispatch_sync (_dataAccessQueue, ^{
61
66
self->_authenticationDelegates [authType] = delegate;
62
67
});
Original file line number Diff line number Diff line change @@ -283,7 +283,8 @@ typedef void(^PFUserLogoutResultBlock)(NSError *_Nullable error);
283
283
// /--------------------------------------
284
284
285
285
/* *
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.
287
288
288
289
@note This method shouldn't be invoked directly unless developing a third party authentication library.
289
290
@see PFUserAuthenticationDelegate
@@ -293,6 +294,16 @@ typedef void(^PFUserLogoutResultBlock)(NSError *_Nullable error);
293
294
*/
294
295
+ (void )registerAuthenticationDelegate : (id <PFUserAuthenticationDelegate>)delegate forAuthType : (NSString *)authType ;
295
296
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
+
296
307
/* *
297
308
Logs in a user with third party authentication credentials.
298
309
Original file line number Diff line number Diff line change @@ -848,6 +848,10 @@ + (void)registerAuthenticationDelegate:(id<PFUserAuthenticationDelegate>)delegat
848
848
[[self authenticationController ] registerAuthenticationDelegate: delegate forAuthType: authType];
849
849
}
850
850
851
+ + (void )unregisterAuthenticationDelegateForAuthType : (NSString *)authType {
852
+ [[self authenticationController ] unregisterAuthenticationDelegateForAuthType: authType];
853
+ }
854
+
851
855
#pragma mark Log In
852
856
853
857
+ (BFTask<__kindof PFUser *> *)logInWithAuthTypeInBackground : (NSString *)authType
You can’t perform that action at this time.
0 commit comments