@@ -44,8 +44,8 @@ using ::firebase::auth::PlayGamesAuthProvider;
44
44
using ::firebase::auth::SignInResult;
45
45
using ::firebase::auth::TwitterAuthProvider;
46
46
using ::firebase::auth::User;
47
- using ::firebase::auth::UserMetadata;
48
47
using ::firebase::auth::UserInfoInterface;
48
+ using ::firebase::auth::UserMetadata;
49
49
50
50
// Set this to true, and set the email/password, to test a custom email address.
51
51
static const bool kTestCustomEmail = false ;
@@ -197,16 +197,14 @@ static void LogVariantMap(const std::map<Variant, Variant>& variant_map,
197
197
int indent);
198
198
199
199
// Log a vector of variants.
200
- static void LogVariantVector (const std::vector<Variant>& variants,
201
- int indent) {
200
+ static void LogVariantVector (const std::vector<Variant>& variants, int indent) {
202
201
std::string indent_string (indent * 2 , ' ' );
203
202
LogMessage (" %s[" , indent_string.c_str ());
204
203
for (auto it = variants.begin (); it != variants.end (); ++it) {
205
204
const Variant& item = *it;
206
205
if (item.is_fundamental_type ()) {
207
206
const Variant& string_value = item.AsString ();
208
- LogMessage (" %s %s," , indent_string.c_str (),
209
- string_value.string_value ());
207
+ LogMessage (" %s %s," , indent_string.c_str (), string_value.string_value ());
210
208
} else if (item.is_vector ()) {
211
209
LogVariantVector (item.vector (), indent + 2 );
212
210
} else if (item.is_map ()) {
@@ -228,12 +226,10 @@ static void LogVariantMap(const std::map<Variant, Variant>& variant_map,
228
226
const Variant& value = it->second ;
229
227
if (value.is_fundamental_type ()) {
230
228
const Variant& string_value = value.AsString ();
231
- LogMessage (" %s%s: %s," , indent_string.c_str (),
232
- key_string.string_value (),
229
+ LogMessage (" %s%s: %s," , indent_string.c_str (), key_string.string_value (),
233
230
string_value.string_value ());
234
231
} else {
235
- LogMessage (" %s%s:" , indent_string.c_str (),
236
- key_string.string_value ());
232
+ LogMessage (" %s%s:" , indent_string.c_str (), key_string.string_value ());
237
233
if (value.is_vector ()) {
238
234
LogVariantVector (value.vector (), indent + 1 );
239
235
} else if (value.is_map ()) {
@@ -636,6 +632,16 @@ extern "C" int common_main(int argc, const char* argv[]) {
636
632
WaitForSignInFuture (phone_future,
637
633
" Auth::SignInWithCredential() phone credential" ,
638
634
kAuthErrorNone , auth);
635
+ if (phone_future.error () == kAuthErrorNone ) {
636
+ User* user = *phone_future.result ();
637
+ Future<User*> update_future =
638
+ user->UpdatePhoneNumberCredential (phone_credential);
639
+ WaitForSignInFuture (
640
+ update_future,
641
+ " user->UpdatePhoneNumberCredential(phone_credential)" ,
642
+ kAuthErrorNone , auth);
643
+ }
644
+
639
645
} else {
640
646
LogMessage (" ERROR: SMS auto-detect time out did not occur." );
641
647
}
@@ -744,7 +750,6 @@ extern "C" int common_main(int argc, const char* argv[]) {
744
750
}
745
751
}
746
752
747
-
748
753
// Sign in anonymously, link an email credential, reauthenticate with the
749
754
// credential, unlink the credential and finally sign out.
750
755
{
@@ -754,8 +759,8 @@ extern "C" int common_main(int argc, const char* argv[]) {
754
759
if (sign_in_anonymously_future.error () == kAuthErrorNone ) {
755
760
User* user = *sign_in_anonymously_future.result ();
756
761
std::string email = CreateNewEmail ();
757
- Credential credential = EmailAuthProvider::GetCredential (
758
- email.c_str (), kTestPassword );
762
+ Credential credential =
763
+ EmailAuthProvider::GetCredential ( email.c_str (), kTestPassword );
759
764
// Link with an email / password credential.
760
765
Future<SignInResult> link_future =
761
766
user->LinkAndRetrieveDataWithCredential (credential);
@@ -773,10 +778,10 @@ extern "C" int common_main(int argc, const char* argv[]) {
773
778
LogSignInResult (*reauth_future.result ());
774
779
}
775
780
// Unlink email / password from credential.
776
- Future<User*> unlink_future = user-> Unlink (
777
- credential.provider ().c_str ());
778
- WaitForSignInFuture (unlink_future, " User::Unlink" ,
779
- kAuthErrorNone , auth);
781
+ Future<User*> unlink_future =
782
+ user-> Unlink ( credential.provider ().c_str ());
783
+ WaitForSignInFuture (unlink_future, " User::Unlink" , kAuthErrorNone ,
784
+ auth);
780
785
}
781
786
auth->SignOut ();
782
787
}
@@ -838,19 +843,22 @@ extern "C" int common_main(int argc, const char* argv[]) {
838
843
auth->SignInAndRetrieveDataWithCredential (email_cred);
839
844
WaitForSignInFuture (sign_in_future,
840
845
" Auth::SignInAndRetrieveDataWithCredential "
841
- " existing email" , kAuthErrorNone , auth);
842
- ExpectTrue (" SignInAndRetrieveDataWithCredentialLastResult matches "
843
- " returned Future" ,
844
- sign_in_future ==
845
- auth->SignInAndRetrieveDataWithCredentialLastResult ());
846
+ " existing email" ,
847
+ kAuthErrorNone , auth);
848
+ ExpectTrue (
849
+ " SignInAndRetrieveDataWithCredentialLastResult matches "
850
+ " returned Future" ,
851
+ sign_in_future ==
852
+ auth->SignInAndRetrieveDataWithCredentialLastResult ());
846
853
if (sign_in_future.error () == kAuthErrorNone ) {
847
854
const SignInResult* sign_in_result = sign_in_future.result ();
848
855
if (sign_in_result != nullptr && sign_in_result->user ) {
849
856
LogMessage (" SignInAndRetrieveDataWithCredential" );
850
857
LogSignInResult (*sign_in_result);
851
858
} else {
852
- LogMessage (" ERROR: SignInAndRetrieveDataWithCredential returned no "
853
- " result" );
859
+ LogMessage (
860
+ " ERROR: SignInAndRetrieveDataWithCredential returned no "
861
+ " result" );
854
862
}
855
863
}
856
864
}
0 commit comments