@@ -447,26 +447,6 @@ Future<AuthResult> Auth::SignInWithCustomToken(const char* token) {
447447 return MakeFuture (&futures, handle);
448448}
449449
450- Future<User*> Auth::SignInWithCustomToken_DEPRECATED (const char * token) {
451- ReferenceCountedFutureImpl& futures = auth_data_->future_impl ;
452- const auto handle =
453- futures.SafeAlloc <User*>(kAuthFn_SignInWithCustomToken_DEPRECATED );
454- JNIEnv* env = Env (auth_data_);
455-
456- jstring j_token = env->NewStringUTF (token);
457- jobject pending_result = env->CallObjectMethod (
458- AuthImpl (auth_data_), auth::GetMethodId (auth::kSignInWithCustomToken ),
459- j_token);
460- env->DeleteLocalRef (j_token);
461-
462- if (!CheckAndCompleteFutureOnError (env, &futures, handle)) {
463- RegisterCallback (pending_result, handle, auth_data_,
464- ReadUserFromSignInResult);
465- env->DeleteLocalRef (pending_result);
466- }
467- return MakeFuture (&futures, handle);
468- }
469-
470450Future<User> Auth::SignInWithCredential (const Credential& credential) {
471451 ReferenceCountedFutureImpl& futures = auth_data_->future_impl ;
472452 const auto handle = futures.SafeAlloc <User>(kAuthFn_SignInWithCredential );
@@ -490,31 +470,6 @@ Future<User> Auth::SignInWithCredential(const Credential& credential) {
490470 return MakeFuture (&futures, handle);
491471}
492472
493- Future<User*> Auth::SignInWithCredential_DEPRECATED (
494- const Credential& credential) {
495- ReferenceCountedFutureImpl& futures = auth_data_->future_impl ;
496- const auto handle =
497- futures.SafeAlloc <User*>(kAuthFn_SignInWithCredential_DEPRECATED );
498- JNIEnv* env = Env (auth_data_);
499-
500- // If the credential itself is in an error state, don't try signing in.
501- if (credential.error_code_ != kAuthErrorNone ) {
502- futures.Complete (handle, credential.error_code_ ,
503- credential.error_message_ .c_str ());
504- } else {
505- jobject pending_result = env->CallObjectMethod (
506- AuthImpl (auth_data_), auth::GetMethodId (auth::kSignInWithCredential ),
507- CredentialFromImpl (credential.impl_ ));
508-
509- if (!CheckAndCompleteFutureOnError (env, &futures, handle)) {
510- RegisterCallback (pending_result, handle, auth_data_,
511- ReadUserFromSignInResult);
512- env->DeleteLocalRef (pending_result);
513- }
514- }
515- return MakeFuture (&futures, handle);
516- }
517-
518473Future<AuthResult> Auth::SignInAndRetrieveDataWithCredential (
519474 const Credential& credential) {
520475 ReferenceCountedFutureImpl& futures = auth_data_->future_impl ;
@@ -539,41 +494,11 @@ Future<AuthResult> Auth::SignInAndRetrieveDataWithCredential(
539494 return MakeFuture (&futures, handle);
540495}
541496
542- Future<SignInResult> Auth::SignInAndRetrieveDataWithCredential_DEPRECATED (
543- const Credential& credential) {
544- ReferenceCountedFutureImpl& futures = auth_data_->future_impl ;
545- const auto handle = futures.SafeAlloc <SignInResult>(
546- kAuthFn_SignInAndRetrieveDataWithCredential_DEPRECATED );
547- JNIEnv* env = Env (auth_data_);
548-
549- // If the credential itself is in an error state, don't try signing in.
550- if (credential.error_code_ != kAuthErrorNone ) {
551- futures.Complete (handle, credential.error_code_ ,
552- credential.error_message_ .c_str ());
553- } else {
554- jobject pending_result = env->CallObjectMethod (
555- AuthImpl (auth_data_), auth::GetMethodId (auth::kSignInWithCredential ),
556- CredentialFromImpl (credential.impl_ ));
557-
558- if (!CheckAndCompleteFutureOnError (env, &futures, handle)) {
559- RegisterCallback (pending_result, handle, auth_data_, ReadSignInResult);
560- env->DeleteLocalRef (pending_result);
561- }
562- }
563- return MakeFuture (&futures, handle);
564- }
565-
566497Future<AuthResult> Auth::SignInWithProvider (FederatedAuthProvider* provider) {
567498 FIREBASE_ASSERT_RETURN (Future<AuthResult>(), provider);
568499 return provider->SignIn (auth_data_);
569500}
570501
571- Future<SignInResult> Auth::SignInWithProvider_DEPRECATED (
572- FederatedAuthProvider* provider) {
573- FIREBASE_ASSERT_RETURN (Future<SignInResult>(), provider);
574- return provider->SignIn_DEPRECATED (auth_data_);
575- }
576-
577502Future<AuthResult> Auth::SignInAnonymously () {
578503 ReferenceCountedFutureImpl& futures = auth_data_->future_impl ;
579504 const auto handle = futures.SafeAlloc <AuthResult>(kAuthFn_SignInAnonymously );
@@ -590,24 +515,6 @@ Future<AuthResult> Auth::SignInAnonymously() {
590515 return MakeFuture (&futures, handle);
591516}
592517
593- Future<User*> Auth::SignInAnonymously_DEPRECATED () {
594- ReferenceCountedFutureImpl& futures = auth_data_->future_impl ;
595- const auto handle =
596- futures.SafeAlloc <User*>(kAuthFn_SignInAnonymously_DEPRECATED );
597- JNIEnv* env = Env (auth_data_);
598-
599- jobject pending_result = env->CallObjectMethod (
600- AuthImpl (auth_data_), auth::GetMethodId (auth::kSignInAnonymously ));
601-
602- if (!CheckAndCompleteFutureOnError (env, &futures, handle)) {
603- RegisterCallback (pending_result, handle, auth_data_,
604- ReadUserFromSignInResult);
605- env->DeleteLocalRef (pending_result);
606- }
607-
608- return MakeFuture (&futures, handle);
609- }
610-
611518Future<AuthResult> Auth::SignInWithEmailAndPassword (const char * email,
612519 const char * password) {
613520 ReferenceCountedFutureImpl& futures = auth_data_->future_impl ;
@@ -640,39 +547,6 @@ Future<AuthResult> Auth::SignInWithEmailAndPassword(const char* email,
640547 return MakeFuture (&futures, handle);
641548}
642549
643- Future<User*> Auth::SignInWithEmailAndPassword_DEPRECATED (
644- const char * email, const char * password) {
645- ReferenceCountedFutureImpl& futures = auth_data_->future_impl ;
646- const auto handle =
647- futures.SafeAlloc <User*>(kAuthFn_SignInWithEmailAndPassword_DEPRECATED );
648-
649- if (!email || strlen (email) == 0 || !password || strlen (password) == 0 ) {
650- futures.Complete (handle,
651- (!email || strlen (email) == 0 ) ? kAuthErrorMissingEmail
652- : kAuthErrorMissingPassword ,
653- kErrorEmptyEmailPassword );
654- return MakeFuture (&futures, handle);
655- }
656-
657- JNIEnv* env = Env (auth_data_);
658- jstring j_email = env->NewStringUTF (email);
659- jstring j_password = env->NewStringUTF (password);
660- jobject pending_result = env->CallObjectMethod (
661- AuthImpl (auth_data_),
662- auth::GetMethodId (auth::kSignInWithEmailAndPassword ), j_email,
663- j_password);
664- env->DeleteLocalRef (j_email);
665- env->DeleteLocalRef (j_password);
666-
667- if (!CheckAndCompleteFutureOnError (env, &futures, handle)) {
668- RegisterCallback (pending_result, handle, auth_data_,
669- ReadUserFromSignInResult);
670- env->DeleteLocalRef (pending_result);
671- }
672-
673- return MakeFuture (&futures, handle);
674- }
675-
676550Future<AuthResult> Auth::CreateUserWithEmailAndPassword (const char * email,
677551 const char * password) {
678552 ReferenceCountedFutureImpl& futures = auth_data_->future_impl ;
@@ -704,52 +578,11 @@ Future<AuthResult> Auth::CreateUserWithEmailAndPassword(const char* email,
704578 return MakeFuture (&futures, handle);
705579}
706580
707- Future<User*> Auth::CreateUserWithEmailAndPassword_DEPRECATED (
708- const char * email, const char * password) {
709- ReferenceCountedFutureImpl& futures = auth_data_->future_impl ;
710- const auto handle = futures.SafeAlloc <User*>(
711- kAuthFn_CreateUserWithEmailAndPassword_DEPRECATED );
712-
713- if (!email || strlen (email) == 0 || !password || strlen (password) == 0 ) {
714- futures.Complete (handle,
715- (!email || strlen (email) == 0 ) ? kAuthErrorMissingEmail
716- : kAuthErrorMissingPassword ,
717- kErrorEmptyEmailPassword );
718- return MakeFuture (&futures, handle);
719- }
720- JNIEnv* env = Env (auth_data_);
721-
722- jstring j_email = env->NewStringUTF (email);
723- jstring j_password = env->NewStringUTF (password);
724- jobject pending_result = env->CallObjectMethod (
725- AuthImpl (auth_data_),
726- auth::GetMethodId (auth::kCreateUserWithEmailAndPassword ), j_email,
727- j_password);
728- env->DeleteLocalRef (j_email);
729- env->DeleteLocalRef (j_password);
730-
731- if (!CheckAndCompleteFutureOnError (env, &futures, handle)) {
732- RegisterCallback (pending_result, handle, auth_data_,
733- ReadUserFromSignInResult);
734- env->DeleteLocalRef (pending_result);
735- }
736- return MakeFuture (&futures, handle);
737- }
738-
739581User Auth::current_user () {
740- User* current_user = current_user_DEPRECATED ();
741- if (current_user != nullptr ) {
742- return *current_user ;
582+ if (!auth_data_) {
583+ // Return an invalid user.
584+ return User ( nullptr ) ;
743585 }
744- // Return an invalid user.
745- return User (auth_data_);
746- }
747-
748- // It's safe to return a direct pointer to `current_user` because that class
749- // holds nothing but a pointer to AuthData, which never changes.
750- // All User functions that require synchronization go through AuthData's mutex.
751- User* Auth::current_user_DEPRECATED () {
752- if (!auth_data_) return nullptr ;
753586 MutexLock lock (auth_data_->future_impl .mutex ());
754587
755588 // auth_data_->current_user should be available after Auth is created because
@@ -758,9 +591,11 @@ User* Auth::current_user_DEPRECATED() {
758591 // persistent loading. However, it is safe to access auth_data_->current_user
759592 // here since FirebaseAuth.getCurrentUser() (Android) is called in
760593 // InitPlatformAuth().
761- User* user =
762- auth_data_->user_impl == nullptr ? nullptr : &auth_data_->current_user ;
763- return user;
594+ if (auth_data_->user_impl == nullptr ) {
595+ // return an invalid user.
596+ return User (nullptr );
597+ }
598+ return auth_data_->current_user ;
764599}
765600
766601std::string Auth::language_code () const {
0 commit comments