@@ -194,6 +194,10 @@ explicit IOSWrappedUserInfo(id<FIRUserInfo> user_info) : user_info_(user_info) {
194194 }
195195 ReferenceCountedFutureImpl &futures = auth_data_->future_impl ;
196196 const auto handle = futures.SafeAlloc <AuthResult>(kUserFn_LinkWithCredential , AuthResult ());
197+ if (!credential.is_valid ()) {
198+ futures.Complete (handle, kAuthErrorInvalidCredential , " Invalid credential is not allowed." );
199+ return MakeFuture (&futures, handle);
200+ }
197201 AuthData *auth_data = auth_data_;
198202 [UserImpl (auth_data)
199203 linkWithCredential: CredentialFromImpl (credential.impl_)
@@ -209,6 +213,10 @@ explicit IOSWrappedUserInfo(id<FIRUserInfo> user_info) : user_info_(user_info) {
209213 }
210214 ReferenceCountedFutureImpl &futures = auth_data_->future_impl ;
211215 const auto handle = futures.SafeAlloc <User *>(kUserFn_LinkWithCredential_DEPRECATED );
216+ if (!credential.is_valid ()) {
217+ futures.Complete (handle, kAuthErrorInvalidCredential , " Invalid credential is not allowed." );
218+ return MakeFuture (&futures, handle);
219+ }
212220 [UserImpl (auth_data_)
213221 linkWithCredential: CredentialFromImpl (credential.impl_)
214222 completion: ^(FIRAuthDataResult *_Nullable auth_result, NSError *_Nullable error) {
@@ -224,6 +232,10 @@ explicit IOSWrappedUserInfo(id<FIRUserInfo> user_info) : user_info_(user_info) {
224232 ReferenceCountedFutureImpl &futures = auth_data_->future_impl ;
225233 const auto handle = auth_data_->future_impl .SafeAlloc <SignInResult>(
226234 kUserFn_LinkAndRetrieveDataWithCredential , SignInResult ());
235+ if (!credential.is_valid ()) {
236+ futures.Complete (handle, kAuthErrorInvalidCredential , " Invalid credential is not allowed." );
237+ return MakeFuture (&futures, handle);
238+ }
227239 AuthData *auth_data = auth_data_;
228240 [UserImpl (auth_data)
229241 linkWithCredential: CredentialFromImpl (credential.impl_)
@@ -279,6 +291,10 @@ explicit IOSWrappedUserInfo(id<FIRUserInfo> user_info) : user_info_(user_info) {
279291 const auto handle = futures.SafeAlloc <User>(kUserFn_UpdatePhoneNumberCredential );
280292
281293#if FIREBASE_PLATFORM_IOS
294+ if (!credential.is_valid ()) {
295+ futures.Complete (handle, kAuthErrorInvalidCredential , " Invalid credential is not allowed." );
296+ return MakeFuture (&futures, handle);
297+ }
282298 FIRPhoneAuthCredential *objc_credential = PhoneAuthCredentialFromImpl (credential.impl_ );
283299 [UserImpl (auth_data_)
284300 updatePhoneNumberCredential: objc_credential
@@ -302,6 +318,10 @@ explicit IOSWrappedUserInfo(id<FIRUserInfo> user_info) : user_info_(user_info) {
302318 const auto handle = futures.SafeAlloc <User *>(kUserFn_UpdatePhoneNumberCredential_DEPRECATED );
303319
304320#if FIREBASE_PLATFORM_IOS
321+ if (!credential.is_valid ()) {
322+ futures.Complete (handle, kAuthErrorInvalidCredential , " Invalid credential is not allowed." );
323+ return MakeFuture (&futures, handle);
324+ }
305325 FIRAuthCredential *objc_credential = CredentialFromImpl (credential.impl_ );
306326 if ([objc_credential isKindOfClass: [FIRPhoneAuthCredential class ]]) {
307327 [UserImpl (auth_data_)
@@ -341,6 +361,10 @@ explicit IOSWrappedUserInfo(id<FIRUserInfo> user_info) : user_info_(user_info) {
341361 }
342362 ReferenceCountedFutureImpl &futures = auth_data_->future_impl ;
343363 const auto handle = futures.SafeAlloc <void >(kUserFn_Reauthenticate );
364+ if (!credential.is_valid ()) {
365+ futures.Complete (handle, kAuthErrorInvalidCredential , " Invalid credential is not allowed." );
366+ return MakeFuture (&futures, handle);
367+ }
344368
345369 [UserImpl (auth_data_)
346370 reauthenticateWithCredential: CredentialFromImpl (credential.impl_)
@@ -359,6 +383,10 @@ explicit IOSWrappedUserInfo(id<FIRUserInfo> user_info) : user_info_(user_info) {
359383 ReferenceCountedFutureImpl &futures = auth_data_->future_impl ;
360384 const auto handle = auth_data_->future_impl .SafeAlloc <AuthResult>(
361385 kUserFn_ReauthenticateAndRetrieveData , AuthResult ());
386+ if (!credential.is_valid ()) {
387+ futures.Complete (handle, kAuthErrorInvalidCredential , " Invalid credential is not allowed." );
388+ return MakeFuture (&futures, handle);
389+ }
362390 AuthData *auth_data = auth_data_;
363391 [UserImpl (auth_data)
364392 reauthenticateWithCredential: CredentialFromImpl (credential.impl_)
@@ -376,6 +404,10 @@ explicit IOSWrappedUserInfo(id<FIRUserInfo> user_info) : user_info_(user_info) {
376404 ReferenceCountedFutureImpl &futures = auth_data_->future_impl ;
377405 const auto handle = auth_data_->future_impl .SafeAlloc <SignInResult>(
378406 kUserFn_ReauthenticateAndRetrieveData_DEPRECATED , SignInResult ());
407+ if (!credential.is_valid ()) {
408+ futures.Complete (handle, kAuthErrorInvalidCredential , " Invalid credential is not allowed." );
409+ return MakeFuture (&futures, handle);
410+ }
379411 AuthData *auth_data = auth_data_;
380412 [UserImpl (auth_data)
381413 reauthenticateWithCredential: CredentialFromImpl (credential.impl_)
0 commit comments