Пример #1
0
 /// <inheritdoc />
 public IObservable <IFirebaseAuthResult> LinkWithGoogle(string idToken, string accessToken)
 {
     return(_authLink
            .LinkToAsync(FirebaseAuthType.Github, accessToken)
            .ToObservable()
            .Select(authLink => new FirebaseAuthResult(authLink)));
 }
Пример #2
0
        public void LinkAccountsFacebookTest()
        {
            FirebaseAuthProvider authProvider = new FirebaseAuthProvider(new FirebaseConfig(ApiKey));

            FirebaseAuthLink auth    = authProvider.SignInAnonymouslyAsync().Result;
            FirebaseAuthLink newAuth = auth.LinkToAsync(FirebaseAuthType.Facebook, FacebookAccessToken).Result;

            newAuth.User.LocalId.Should().Be(auth.User.LocalId);
            newAuth.User.FirstName.Should().BeEquivalentTo(FacebookTestUserFirstName);
            newAuth.FirebaseToken.Should().NotBeNullOrWhiteSpace();
        }
Пример #3
0
        public void LinkAccountsTest()
        {
            FirebaseAuthProvider authProvider = new FirebaseAuthProvider(new FirebaseConfig(ApiKey));
            string email = $"abcd{new Random().Next()}@test.com";

            FirebaseAuthLink auth    = authProvider.SignInAnonymouslyAsync().Result;
            FirebaseAuthLink newAuth = auth.LinkToAsync(email, "test1234").Result;

            newAuth.User.Email.Should().BeEquivalentTo(email);
            newAuth.User.LocalId.Should().Be(auth.User.LocalId);
            newAuth.FirebaseToken.Should().NotBeNullOrWhiteSpace();
        }
Пример #4
0
        //procedura per il login
        async void Sign_in_btn_Clicked(System.Object sender, System.EventArgs e)
        {
            if (Entry_Email.Text != null && Entry_Password.Text != null)
            {
                string emailLowerCase = Entry_Email.Text.ToLower();

                FirebaseAuthProvider authProvider = new FirebaseAuthProvider(new FirebaseConfig(AuthFirebase.Instance.GetKey()));
                try
                {
                    FirebaseAuthLink auth = await authProvider.SignInWithEmailAndPasswordAsync(Entry_Email.Text, Entry_Password.Text);

                    FirebaseAuthLink content = await auth.LinkToAsync(Entry_Email.Text, Entry_Password.Text);

                    string serializedcontnet = JsonConvert.SerializeObject(content);

                    Preferences.Set("MyLoginToken", serializedcontnet);
                    Preferences.Set("UserEmailFirebase", emailLowerCase.Replace(".", "-").Replace("@", "-at-"));
                    await Navigation.PushAsync(new MasterDetail());

                    if (content.User.IsEmailVerified == false)
                    {
                        bool action = await App.Current.MainPage.DisplayAlert("Attention.", "Your account is not verified yet.\n Send verification email again?", "Yes", "No");

                        if (action)
                        {
                            await authProvider.SendEmailVerificationAsync(content.FirebaseToken);
                        }
                    }
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                    await App.Current.MainPage.DisplayAlert("Alert.", "Invalid email or password.", "Ok");
                }
            }
        }