private void LoginButton_Click(object sender, EventArgs e)
        {
            string email, password;

            email    = emailText.EditText.Text;
            password = passwordText.EditText.Text;

            if (!email.Contains("@"))
            {
                Snackbar.Make(rootView, "Please provide a valid email", Snackbar.LengthShort).Show();
                return;
            }
            else if (password.Length < 8)
            {
                Snackbar.Make(rootView, "Please provide a valid password", Snackbar.LengthShort).Show();
                return;
            }

            TaskCompletionListener taskCompletionListener = new TaskCompletionListener();

            taskCompletionListener.Success += TaskCompletionListener_Success;
            taskCompletionListener.Failure += TaskCompletionListener_Failure;

            mAuth.SignInWithEmailAndPassword(email, password)
            .AddOnSuccessListener(taskCompletionListener)
            .AddOnFailureListener(taskCompletionListener);
        }
Exemplo n.º 2
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            SetContentView(Resource.Layout.activity_main);

            // To use this you have to set up a project in the Firebase console and add the google-services.json file
            var baseOptions = FirebaseOptions.FromResource(Application.Context);
            var options     = new FirebaseOptions.Builder(baseOptions)
                              .SetProjectId(baseOptions.StorageBucket.Split('.')[0])
                              .Build();

            var fa = FirebaseApp.InitializeApp(Application.Context, options, "Xamarin");

            //FirebaseApp fa = FirebaseApp.InitializeApp(Application.Context);

            mAuth = FirebaseAuth.GetInstance(fa);

            if (mAuth == null)
            {
                Console.WriteLine("mAuth is null");
            }

            AuthCredential credential = EmailAuthProvider.GetCredential("*****@*****.**", "password");

            var creds = mAuth.SignInWithEmailAndPassword("*****@*****.**", "password"); // Here the program crashes due to a null mAuth
        }
Exemplo n.º 3
0
        private void LoginUser(string email, string password)
        {
            //using signing in  with email and password method
            auth.SignInWithEmailAndPassword(email, password) //error is here when I run it: System.NullReferenceException: <Timeout exceeded getting exception details>

            .AddOnCompleteListener(this);
        }
Exemplo n.º 4
0
        private void LoginBtn_Click(object sender, EventArgs e)
        {
            string email, pass;

            email = emailTxt.EditText.Text;
            pass  = passTxt.EditText.Text;

            if (!email.Contains("@"))
            {
                Toast.MakeText(this, " Please try a valid email  ", ToastLength.Short).Show();
            }
            else if (pass.Length < 8)
            {
                Toast.MakeText(this, " Please provide a valid password  ", ToastLength.Short).Show();
            }

            TaskCompletionListener TaskCompletionListener = new TaskCompletionListener();

            TaskCompletionListener.Success += TaskCompetionListener_Success;
            TaskCompletionListener.Failer  += TaskCompetionListener_Failer;

            dbAuth.SignInWithEmailAndPassword(email, pass)
            .AddOnSuccessListener(TaskCompletionListener)
            .AddOnFailureListener(TaskCompletionListener)
            ;
        }
Exemplo n.º 5
0
        private void LoginUser(string mail, string password)
        {
            if (mail.ToString().Trim() == "")
            {
                loginmail.SetError("Required", null);
            }
            if (!mail.ToString().Contains("@"))
            {
                loginmail.SetError("Email Not Valid", null);
            }
            if (password.ToString().Trim() == "")
            {
                loginpass.SetError("Required", null);
            }
            else
            {
                pgblogin.Visibility = ViewStates.Visible;

                /* loginbutt.Visibility = ViewStates.Gone;
                 * loginmail.Visibility = ViewStates.Gone;
                 * loginpass.Visibility = ViewStates.Gone;
                 * forgotpass.Visibility = ViewStates.Gone;
                 * emaillay.Visibility = ViewStates.Gone;
                 * passlay.Visibility = ViewStates.Gone;*/
                signup.Visibility      = ViewStates.Gone;
                loginHolder.Visibility = ViewStates.Gone;
                auth.SignInWithEmailAndPassword(mail, password)
                .AddOnCompleteListener(this, this);
            }
        }
Exemplo n.º 6
0
        private void LoginButton_Click(object sender, EventArgs e)
        {
            string email, password;

            email    = emailText.EditText.Text;
            password = passwordText.EditText.Text;

            if (!email.Contains("@"))
            {
                Toast.MakeText(this, "Please provide a valid email address", ToastLength.Short).Show();
                return;
            }
            else if (password.Length < 8)
            {
                Toast.MakeText(this, "Please provide a valid password", ToastLength.Short).Show();
                return;
            }

            ShowProgressDialogue("Verifying you ...");
            mAuth.SignInWithEmailAndPassword(email, password).AddOnSuccessListener(taskCompletionListeners)
            .AddOnFailureListener(taskCompletionListeners);

            taskCompletionListeners.Sucess += (success, args) =>
            {
                CloseProgressDialogue();
                StartActivity(typeof(MainActivity));
                Finish();
            };

            taskCompletionListeners.Failure += (success, args) =>
            {
                CloseProgressDialogue();
                Toast.MakeText(this, "Login Failed : " + args.Cause, ToastLength.Short).Show();
            };
        }
Exemplo n.º 7
0
        //Try to log in
        private void LoginButton_Click(object sender, EventArgs e)
        {
            string em, p;

            //link variables to user input
            em = input_email.Text;
            p  = input_pwd.Text;

            //email invalid if no @ sign
            if (!em.Contains("@"))
            {
                Snackbar.Make(activity_main, "Please provide valid email", Snackbar.LengthShort).Show();
                return;
            }
            //password invalid if below 8 characters
            else if (p.Length < 8)
            {
                Snackbar.Make(activity_main, "Please provide valid password", Snackbar.LengthShort).Show();
                return;
            }
            //Initialize task completion listener and link to functions
            TaskCompletionListener taskCompletionListener = new TaskCompletionListener();

            taskCompletionListener.Success += TaskCompletionListener_Success;
            taskCompletionListener.Failure += TaskCompletionListener_Failure;

            //try to sign in with email and password
            mAuth.SignInWithEmailAndPassword(em, p)
            .AddOnSuccessListener(taskCompletionListener)
            .AddOnFailureListener(taskCompletionListener);
        }
Exemplo n.º 8
0
    public void LogIn()
    {
        // Try to log in
        string emailText    = email.GetComponentInChildren <TMP_InputField>().text;
        string passwordText = password.GetComponentInChildren <TMP_InputField>().text;

        FirebaseAuth.SignInWithEmailAndPassword(emailText, passwordText, gameObject.name, "SuccessLogin", "FailLogin");
    }
Exemplo n.º 9
0
        private void Dialog_onSignInComplete(object sender, onSignInEventArgs e)
        {
            login_inputMail     = e.email;
            login_inputPassword = e.password;
            login_rememberMe    = e.zapamtiMe;

            auth.SignInWithEmailAndPassword(login_inputMail, login_inputPassword).AddOnSuccessListener(this, this).AddOnFailureListener(this, this);
            progressBar.Visibility = ViewStates.Visible;
        }
Exemplo n.º 10
0
        private void LoginUser(string email, string password)
        {
            TaskCompletionListener.Success += TaskCompletionListener_Success;
            TaskCompletionListener.Failure += TaskCompletionListener_Failure;

            mAuth.SignInWithEmailAndPassword(email, password)
            .AddOnSuccessListener(this, TaskCompletionListener)
            .AddOnFailureListener(this, TaskCompletionListener);
        }
Exemplo n.º 11
0
        private void InitFirebase(bool forcestart)
        {
            try
            {
                // Initialize Firebase app
                if (app == null)
                {
                    if (string.IsNullOrWhiteSpace(ApplicationId) || string.IsNullOrWhiteSpace(ApiKey) || string.IsNullOrWhiteSpace(DatabaseUrl))
                    {
                        // Show auth dialog to set firebase variables and authentication
                        //ShowAuthDialog();
                        return;
                    }

                    var options = new FirebaseOptions.Builder()
                                  .SetApplicationId(ApplicationId)
                                  .SetApiKey(ApiKey)
                                  .SetDatabaseUrl(DatabaseUrl)
                                  .Build();

                    app = FirebaseApp.InitializeApp(this, options);
                }

                // Get authorization on our Firebase app
                if (auth == null)
                {
                    auth = FirebaseAuth.GetInstance(app);

                    auth.SignInWithEmailAndPassword(Email, Password); //.AddOnCompleteListener(OnCompleteAuth);
                }

                // Get a database reference
                if (databaseReference == null)
                {
                    var db = FirebaseDatabase.GetInstance(app);
                    db.SetPersistenceEnabled(true);

                    // All our operations will be done on device id child
                    databaseReference = db.GetReference("/"); // + DateTime.Now.ToString("/yyyyMMdd"));

                    Load();
                }

                if (forcestart)
                {
                    databaseReference.Child("devices/" + android_id + "/enabled").SetValue(1);
                    //databaseReference.Child("devices/" + android_id + "/working").SetValue(1);
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                NotificationText(ex.Message, string.Empty);
            }
        }
Exemplo n.º 12
0
 public void Login(object sender, EventArgs e)
 {
     try
     {
         auth.SignInWithEmailAndPassword(Emails.Text, Passwords.Text).AddOnCompleteListener(this);
     }
     catch
     {
         Toast.MakeText(ApplicationContext, "Please Fill Email and Password Field", ToastLength.Long).Show();
     }
 }
Exemplo n.º 13
0
 // login user if all fields are filled
 private void LoginUser(object sender, EventArgs e)
 {
     if (!string.IsNullOrEmpty(username.Text) && !string.IsNullOrEmpty(password.Text))
     {
         auth.SignInWithEmailAndPassword(username.Text, password.Text).AddOnSuccessListener(this).AddOnFailureListener(this);
     }
     else
     {
         errorText.Text       = "All fields must be filled";
         errorText.Visibility = ViewStates.Visible;
     }
 }
Exemplo n.º 14
0
 //confirm password
 private void LoginUser(string email, string password)
 {
     try
     {
         //checking the email is exsisting and if the password matches in the email
         auth.SignInWithEmailAndPassword(email, password)
         .AddOnCompleteListener(this);
     }
     catch (Exception e)
     {
         //create a exception if the email is blank
         Toast.MakeText(this, "Failed", ToastLength.Short).Show();
     }
 }
Exemplo n.º 15
0
        private Boolean LoginUser(string email, string password)
        {
            Console.WriteLine("Llego aquí");

            // try
            // {
            auth.SignInWithEmailAndPassword(email, password);
            // }
            // {
            //   return false;

            //}

            return(true);
        }
Exemplo n.º 16
0
        private void LoginButton_Click(object sender, EventArgs e)
        {
            string email    = _textInputEmail.EditText.Text;
            string password = _textInputPassword.EditText.Text;

            ShowProgressDialogue();

            TaskCompletionListeners taskCompletionListener = new TaskCompletionListeners();

            taskCompletionListener.Successful += TaskCompletionListener_Successful;
            taskCompletionListener.Failure    += TaskCompletionListener_Failure;

            _mAuth.SignInWithEmailAndPassword(email, password)
            .AddOnSuccessListener(this, taskCompletionListener)
            .AddOnFailureListener(this, taskCompletionListener);
        }
Exemplo n.º 17
0
 public async void SteamAuth(ulong userid)
 {
     SteamUserId       = userid;
     firebase_database = new DatabaseHandler();
     if (await firebase_database.AccountExistsAsync(SteamUserId.ToString()))
     {
         // If the Steam user exists, sign them in with the Steam user ID appended to '@clanbutton.com'.
         auth.SignInWithEmailAndPassword($"{SteamUserId.ToString()}@clanbutton.com", "nopass");
         StartActivity(new Android.Content.Intent(this, typeof(MainActivity)));
         Finish();
     }
     else
     {
         // Otherwise, create the user.
         auth.CreateUserWithEmailAndPassword($"{SteamUserId.ToString()}@clanbutton.com", "nopass").AddOnCompleteListener(this);
         // This then calls the OnCompleteListener method OnComplete().
     }
 }
Exemplo n.º 18
0
        private void LoginButton_Click(object sender, EventArgs e)
        {
            string email, password;

            email    = textInputEmail.EditText.Text;
            password = textInputPassword.EditText.Text;

            // show loader
            ShowProgressDialogue();

            // instance of task completion listener
            TaskCompletionListener taskCompletionListener = new TaskCompletionListener();

            taskCompletionListener.Success += TaskCompletionListener_Success;
            taskCompletionListener.Failure += TaskCompletionListener_Failure;

            // sign-in user
            mAuth.SignInWithEmailAndPassword(email, password)
            .AddOnSuccessListener(this, taskCompletionListener)
            .AddOnFailureListener(this, taskCompletionListener);
        }
        private void Loginbtn_Click(object sender, EventArgs e)
        {
            string email, password;

            email    = Emailtxt.EditText.Text;
            password = passwordtxt.EditText.Text;

            ShowProgressDialog();

            TaskComletionListener taskComletionListener = new TaskComletionListener();

            taskComletionListener.Success += TaskComletionListener_Success;
            taskComletionListener.Failure += TaskComletionListener_Failure;

            if (!email.Contains("@"))
            {
                CloseProgressDialog();
                Snackbar.Make(rootview, "Please Enter Right Email", Snackbar.LengthShort).Show();
                return;
            }
            else if (password == null)
            {
                CloseProgressDialog();
                Snackbar.Make(rootview, "please Enter password", Snackbar.LengthShort).Show();
                return;
            }


            try
            {
                mAuth.SignInWithEmailAndPassword(email, password)
                .AddOnSuccessListener(this, taskComletionListener)
                .AddOnFailureListener(this, taskComletionListener);
            }
            catch (Exception)
            {
                CloseProgressDialog();
                Snackbar.Make(rootview, "Oppse Some thing is Wrong !!", Snackbar.LengthShort).Show();
            }
        }
Exemplo n.º 20
0
        private void LoginUser(string email, string password)
        {
            password             = AppData.EncryptPassword(password);
            AppData.LoggedInUser = email;
            var data         = db.SelectUserTable();                                                            //retrieve all users in the user table
            var userData     = data.Where(x => x.Username == email && x.Password == password).FirstOrDefault(); //getting the matching user
            var reachability = new Reachability.Net.XamarinAndroid.Reachability();                              //check network

            if (reachability.IsHostReachable(ReachableHost))
            {
                auth.SignInWithEmailAndPassword(email, password); //firebase auth signin
            }
            if (userData != null)
            {
                Toast.MakeText(this, "Login Success", ToastLength.Short).Show();//go to dashboard on succesful user login
                StartActivity(new Android.Content.Intent(this, typeof(Dashboard)));
            }
            else
            {
                Toast.MakeText(this, "Login Failed", ToastLength.Short).Show();
            }
        }
Exemplo n.º 21
0
        private void LoginUser(string email, string pass)
        {
#pragma warning disable CS0618 // El tipo o el miembro están obsoletos
            process = new ProgressDialog(this);
#pragma warning restore CS0618 // El tipo o el miembro están obsoletos
            if (Error())
            {
                auth.SignInWithEmailAndPassword(email, pass)
                .AddOnCompleteListener(this);
                process.SetMessage("Validando informacion, espere.");
                process.Show();
            }
            else
            {
                if (process.IsShowing)
                {
                    process.Dismiss();
                }
                Snackbar snackBar = Snackbar.Make(loginLayout, "Login Failed, campos vacios o email invalido", Snackbar.LengthShort);
                snackBar.Show();
            }
        }
Exemplo n.º 22
0
        private void Login(string email, string password)
        {
            //Login funcionality
            if (!Helpers.Helper.IsValidEmail(email))
            {
                Toast.MakeText(this, "Please provide a valid email", ToastLength.Short).Show();
                return;
            }
            auth.SignInWithEmailAndPassword(email, password)
            .AddOnSuccessListener(listener)
            .AddOnFailureListener(listener);

            //Login failed
            listener.Failure += (s, args) =>
            {
                Toast.MakeText(this, "Signing up failed due to: " + args.Cause, ToastLength.Short).Show();
            };

            listener.Success += (s, args) =>
            {
                StartActivity(typeof(MainActivity));
                FinishAffinity();
            };
        }
Exemplo n.º 23
0
 private void LoginUser(string email, string password)
 {
     auth.SignInWithEmailAndPassword(email, password).AddOnCompleteListener(this);
 }
Exemplo n.º 24
0
 /// <summary>
 /// signs in with email and password
 /// </summary>
 /// <param name="email">email</param>
 /// <param name="password">email</param>
 /// <returns>task that is suppose to sign in</returns>
 public Task SignIn(string email, string password)
 {
     return(auth.SignInWithEmailAndPassword(email, password));
 }
Exemplo n.º 25
0
        private void ShowAuthDialog()
        {
            // Create transaction to show our add item dialog on this activity
            var transaction    = FragmentManager.BeginTransaction();
            var dialogFragment = new AuthDialog(ApplicationId, ApiKey, DatabaseUrl, Email, Password);

            // Do staff with email/password, when we press authenticate on the dialog
            dialogFragment.Dismissed += (s, e) =>
            {
                // Hide auth button
                authButton.Visibility = ViewStates.Gone;
                // Show loading again
                loading.Visibility = ViewStates.Visible;

                // Set Firebase variables
                ApplicationId = e.ApplicationId;
                ApiKey        = e.ApiKey;
                DatabaseUrl   = e.DatabaseUrl;

                // Save Firebase variables on local preferences
                ISharedPreferences       prefs  = PreferenceManager.GetDefaultSharedPreferences(this);
                ISharedPreferencesEditor editor = prefs.Edit();
                editor.PutString("ApplicationId", ApplicationId);
                editor.PutString("ApiKey", ApiKey);
                editor.PutString("DatabaseUrl", DatabaseUrl);
                editor.PutString("Email", Email);
                editor.Apply();

                if (app == null)
                {
                    // Needs to initialize Firebase app first
                    InitFirebase();
                    return;
                }

                OnCompleteAuthListener OnCompleteAuth = new OnCompleteAuthListener();
                OnCompleteAuth.Raised += (se, ev) =>
                {
                    if (ev.task.IsSuccessful)
                    {
                        Toast.MakeText(this, "User authenticated", ToastLength.Short).Show();

                        // Load things
                        Load();
                    }
                    else
                    {
                        Toast.MakeText(this, ev.task.Exception.Message, ToastLength.Short).Show();
                        // Show again auth dialog
                        ShowAuthDialog();
                    }
                };

                auth.SignInWithEmailAndPassword(e.User, e.Password).AddOnCompleteListener(OnCompleteAuth);
            };

            // If we show dialog title, specify if we are adding or editing an existing item
            string title = GetString(Resource.String.authentication);

            // Show dialog
            dialogFragment.Show(transaction, title);


            // Hide loading
            if (loading != null)
            {
                loading.Visibility = ViewStates.Gone;
            }
            // Show auth button (user can press back)
            if (authButton != null)
            {
                authButton.Visibility = ViewStates.Visible;
            }
        }
Exemplo n.º 26
0
 public void SignInWithEmailAndPassword() =>
 FirebaseAuth.SignInWithEmailAndPassword(emailInputField.text, passwordInputField.text, gameObject.name, "DisplayInfo", "DisplayErrorObject");
Exemplo n.º 27
0
 private void Login_User(string check_email, string check_password)
 {
     auth.SignInWithEmailAndPassword(check_email, check_password).AddOnCompleteListener(this);
 }