Ejemplo n.º 1
0
        private async void SignUp()
        {
            SignUpPage signUpPage = new SignUpPage();

            if (string.IsNullOrEmpty(Email) || string.IsNullOrEmpty(Password))
            {
                await App.Current.MainPage.DisplayAlert("Hata", "Lütfen Email ve Parola Giriniz!", "OK");
            }
            var emailPattern = "^([\\w\\.\\-]+)@([\\w\\-]+)((\\.(\\w){2,3})+)$";

            if (!String.IsNullOrWhiteSpace(email) && !(Regex.IsMatch(Email, emailPattern)))
            {
                await App.Current.MainPage.DisplayAlert("Hata", "Geçersiz Email", "OK");
            }
            else
            {
                var user = await FirebaseHelper.AddUser(Email, Password);

                if (user)
                {
                    await App.Current.MainPage.DisplayAlert("Başarılı", "Kayıt Başarılı", "Ok");

                    await App.Current.MainPage.Navigation.PushAsync(new LoginPage());
                }
                else
                {
                    await App.Current.MainPage.DisplayAlert("Hata", "Kayıt Başarısız!", "OK");
                }
            }
        }
Ejemplo n.º 2
0
        async void RegisterProcedure(object sender, EventArgs e)
        {
            if (RegisterEmail.Text.Equals(null) || RegisterPassword.Text.Equals(null))
            {
                await DisplayAlert("Register", "Registration failed, You must enter both an email and a password", "Ok");

                return;
            }
            string email        = RegisterEmail.Text;
            var    existingUser = await firebaseHelper.GetUser(email);

            if (existingUser != null && existingUser.Email.Equals(email))
            {
                await DisplayAlert("Register", "Register failed, a user with the same email address already exists", "Ok");

                return;
            }
            if (!RegisterPasswordConfirm.Text.Equals(RegisterPassword.Text))
            {
                await DisplayAlert("Register", "Register failed, the two passwords must match", "Ok");

                return;
            }
            await firebaseHelper.AddUser(email, RegisterPassword.Text);

            await DisplayAlert("Register", "Register Succeeded, your account has been created!", "Ok");

            Application.Current.Properties["email"]        = email;
            Application.Current.Properties["stayLoggedIn"] = StayLoggedIn.IsToggled;
            await Navigation.PushAsync(new StatusPage());
        }
Ejemplo n.º 3
0
        /* METHODS */
        private async void SignUp()
        {
            // If the fields are empty
            if (string.IsNullOrEmpty(Email) || string.IsNullOrEmpty(Password) || string.IsNullOrEmpty(FirstName) || string.IsNullOrEmpty(LastName))
            {
                await App.Current.MainPage.DisplayAlert("Empty Values", "Please make sure to fill in all the spaces", "OK");
            }

            else
            {
                var user = await FirebaseHelper.AddUser(FirstName, LastName, Email, Password);

                if (user)
                {
                    await App.Current.MainPage.DisplayAlert("SignUp Success", "", "Ok");

                    //Navigate to MainPage
                    Application.Current.MainPage = new MainPage(); // Make this asynchronous

                    Email     = string.Empty;
                    Password  = string.Empty;
                    FirstName = string.Empty;
                    LastName  = string.Empty;
                }

                else
                {
                    await App.Current.MainPage.DisplayAlert("Error", "We ran into an error whiles signing up, please check your network", "OK");
                }
            }
        }
Ejemplo n.º 4
0
        private async void SignUp_Button_Clicked(object sender, EventArgs e)
        {
            if (string.IsNullOrWhiteSpace(email.Text) || string.IsNullOrWhiteSpace(Password.Text) || string.IsNullOrWhiteSpace(Name.Text) || string.IsNullOrWhiteSpace(Password1.Text) || string.IsNullOrWhiteSpace(address.Text) || string.IsNullOrWhiteSpace(phone.Text))
            {
                await DisplayAlert("Empty Values", "Please fill all the details", "OK");
            }
            else
            if (Password.Text != Password1.Text)
            {
                await DisplayAlert("Error", "Passwords do not match", "OK");
            }
            else
            {
                await firebaseHelper.AddUser(Name.Text, phone.Text, Password.Text, email.Text, address.Text);

                Name.Text      = String.Empty;
                phone.Text     = String.Empty;
                Password.Text  = String.Empty;
                Password1.Text = String.Empty;
                email.Text     = String.Empty;
                address.Text   = String.Empty;
                await DisplayAlert("Sign up successful", "", "OK");

                App.Current.MainPage = new View.LoginPage();
            }
        }
        public async void Button_Clicked(object sender, EventArgs e)
        {
            string num    = id.Text;
            int    length = num.Length;

            if (string.IsNullOrEmpty(username.Text) || string.IsNullOrEmpty(pswd.Text)) //check if entry is empty
            {
                await App.Current.MainPage.DisplayAlert(" ", "Please enter Email and Password", "OK");
            }
            else if (pswd.Text != confpswd.Text) //check if password matches
            {
                await App.Current.MainPage.DisplayAlert(" ", "Passwords do not match", "OK");
            }
            else if (string.IsNullOrEmpty(id.Text)) //check if entry is empty
            {
                await App.Current.MainPage.DisplayAlert(" ", "Please enter CSUSM ID number", "OK");
            }
            else if (type.SelectedIndex == -1) //check if user has chosen an option
            {
                await App.Current.MainPage.DisplayAlert(" ", "Please choose type of user", "OK");
            }
            else if (length < 9) //check if the ID Number is valid
            {
                await App.Current.MainPage.DisplayAlert(" ", "Please enter a valid CSUSM ID number", "OK");
            }
            else
            {
                var person = await FirebaseHelper.GetUser(username.Text); //check if username exists or not

                var idNum = await FirebaseHelper.GetUser1(id.Text);       //check if CSUSM ID exists or not

                if (person != null)
                {
                    await this.DisplayAlert("Error", "Username already exists", "Ok");
                }
                else if (idNum != null)
                {
                    await this.DisplayAlert("Error", "CSUSM ID number already exists", "Ok");
                }
                else
                {
                    string name = type.Items[type.SelectedIndex];

                    var user = await FirebaseHelper.AddUser(fName.Text, lName.Text, username.Text, pswd.Text, name, id.Text); //add user's info to the database

                    if (user)
                    {
                        await this.DisplayAlert(" ", "You have sucessfully registered", "Ok");

                        await Navigation.PushModalAsync(new MainPage());
                    }
                    else
                    {
                        await this.DisplayAlert("Error", "Signing Up Failed", "OK");
                    }
                }
            }
        }
Ejemplo n.º 6
0
        public WelcomePage()
        {
            InitializeComponent();

            loginLabel.Text = "You are not logged in!\nGo back and try again.";

            idLabel.IsVisible     = false;
            givenLabel.IsVisible  = false;
            familyLabel.IsVisible = false;
            emailLabel.IsVisible  = false;

            personalInfoButton.IsVisible = false;
            tripButton.IsVisible         = false;

            CrossGoogleClient.Current.OnLogin += async(s, a) =>
            {
                switch (a.Status)
                {
                case GoogleActionStatus.Completed:
                    loginLabel.Text        = "Logged in! Loading your data...";
                    logoutButton.IsVisible = false;

                    App.user.Id         = a.Data.Id;
                    App.user.GivenName  = a.Data.GivenName;
                    App.user.FamilyName = a.Data.FamilyName;
                    App.user.Email      = a.Data.Email;

                    var currentUser = await firebaseHelper.GetUser(App.user.Id);

                    if (currentUser == null)
                    {
                        isNewUser = true;
                        await firebaseHelper.AddUser(App.user);
                    }
                    else
                    {
                        App.user.Age         = currentUser.Age;
                        App.user.BikerStatus = currentUser.BikerStatus;
                        App.user.Gender      = currentUser.Gender;
                        App.user.Weight      = currentUser.Weight;

                        if (App.user.Gender.Equals("N/A"))
                        {
                            noPersonalInfo = true;
                        }
                    }

                    updatePageOnLogin();

                    App.loggedIn = true;
                    break;
                }
            };
        }
Ejemplo n.º 7
0
        private async void RegisterButtonClicked(object sender, EventArgs e)
        {
            User user = await firebaseHelper.GetUser(loginB.Text);

            if (user == null)
            {
                await firebaseHelper.AddUser((loginB.Text), passB.Text);

                loginB.Text = string.Empty;
                passB.Text  = string.Empty;
                await DisplayAlert("Success", "User Added Successfully", "OK");
            }
            else
            {
                await DisplayAlert("Failed", "User already registered", "OK");
            }
        }
Ejemplo n.º 8
0
        public async void MapPage(object sender, EventArgs e)
        {
            if (firstnameEdit.Text != null && lastnameEdit.Text != null && cityEdit.Text != null && usernameEdit.Text != null &&
                passwordEdit.Text != null && confirmPassEdit.Text != null && passwordEdit.Text == confirmPassEdit.Text)
            {
                await firebaseHelper.AddUser(usernameEdit.Text, passwordEdit.Text, firstnameEdit.Text, lastnameEdit.Text,
                                             emailEdit.Text, cityEdit.Text);

                Console.WriteLine("User added");
                firstnameEdit.Text   = String.Empty;
                lastnameEdit.Text    = String.Empty;
                cityEdit.Text        = String.Empty;
                usernameEdit.Text    = String.Empty;
                passwordEdit.Text    = String.Empty;
                confirmPassEdit.Text = String.Empty;
                StartActivity(typeof(MapActivity));
            }
        }
Ejemplo n.º 9
0
        private async void BtnCreateUser_Clicked(object sender, EventArgs e)
        {
            if (Connectivity.NetworkAccess != NetworkAccess.Internet)
            {
                await DisplayAlert("No Internet", "", "OK");

                return;
            }

            try
            {
                var isValid = true;

                if (string.IsNullOrEmpty(txtUsername.Text))
                {
                    isValid = false;
                }
                else if (string.IsNullOrEmpty(txtPassword.Text))
                {
                    isValid = false;
                }

                if (isValid)
                {
                    await firebaseHelper.AddUser(txtUsername.Text.Trim(), txtPassword.Text.Trim());

                    txtUsername.Text = string.Empty;
                    txtPassword.Text = string.Empty;
                    await DisplayAlert("Success", "Users Added Successfully", "OK");

                    var allPersons = await firebaseHelper.GetAllUsers();

                    lstPersons.ItemsSource = allPersons;
                }
                else
                {
                    await DisplayAlert("Error!", "Fields can't be empty ", "OK");
                }
            }
            catch (Exception ex)
            {
                await DisplayAlert("Error: ", ex.ToString(), "OK");
            }
        }
Ejemplo n.º 10
0
        private async void Btn_signUp_OnClicked(object sender, EventArgs e)
        {
            //Boş mu diye kontrol ediyor sadece.
            if (!string.IsNullOrWhiteSpace(tb_mail.Text) || !string.IsNullOrWhiteSpace(tb_password.Text) || !string.IsNullOrWhiteSpace(tb_fullname.Text))
            {
                //İçinde başka kontroller de yapılabilir güvenlik için.
                await firebaseHelper.AddUser(tb_mail.Text, tb_password.Text, tb_fullname.Text);

                tb_mail.Text     = string.Empty;
                tb_password.Text = string.Empty;
                await DisplayAlert("Tebrikler!", "Kayıt işlemini tamamladın. Aramıza Hoşgeldin.", "Tamam");

                await Navigation.PushAsync(new Home(), true);
            }
            else
            {
                DisplayAlert("Hata", "Gerekli Alanları Doldurunuz!", "Geri");
            }
        }
Ejemplo n.º 11
0
        private async void Button_Clicked(object sender, EventArgs e)
        {
            Users kullanici = new Users();
            bool  ctrl      = false;

            if (ad.Text != "" && soyad.Text != "" && mail.Text != "" && password.Text != "" && ad.Text != null && soyad.Text != null && mail.Text != null && password.Text != null)
            {
                kullanici.Ad            = ad.Text.Trim();
                kullanici.Soyad         = soyad.Text.Trim();
                kullanici.KullaniciMail = mail.Text.Trim();
                kullanici.Parola        = password.Text.Trim();
                kullanici.Tarih         = DateTime.Now;
                ctrl = true;
            }
            else
            {
                ctrl = false;
            }

            //var FBLogin = DependencyService.Get<ILogin>();
            //string token = await FBLogin.DoRegisterWithEP(kullanici.KullaniciMail,kullanici.Parola);
            //kullanici.KullaniciKey = token;
            if (ctrl)
            {
                if (await fb.AddUser(kullanici))
                {
                    await DisplayAlert("Kayıt Başarılı", "Başarıyla kayıt oldunuz.", "Tamam");

                    await Navigation.PopAsync();
                }

                else
                {
                    await DisplayAlert("Hata", "Bu Kullanıcı Adı Kullanılıyor.", "Tamam");
                }
            }
            else
            {
                await DisplayAlert("Hata", "Tüm Bilgileri Eksiksiz Doldurduğunuzdan Emin Olun!", "Tamam");
            }
        }
Ejemplo n.º 12
0
        public async Task GenerateFakeUsers()
        {
            Random rnd = new Random();

            Debug.WriteLine("Start Generating Fake Users");

            for (int i = 0; i < 100; i += 1)
            {
                float lat = (float)(latitude + rnd.NextDouble() - 0.5);
                float lon = (float)(longitude + rnd.NextDouble() - 0.5);

                string email    = "fake" + i.ToString() + "@fake.com";
                string password = "******";

                Debug.WriteLine("Create " + email + " at " + lat.ToString() + ", " + lon.ToString());
                // await firebaseHelper.DeleteUser(email);
                await firebaseHelper.AddUser(email, password);

                await firebaseHelper.UpdateLocation(email, lat, lon);

                await firebaseHelper.UpdateStatus(email, (StatusEnum)(i % 4));
            }
        }
        private async void BtnAdd_Clicked(object sender, EventArgs e)
        {
            var result = await firebaseHelper.FindUserByLogin(txtUsername.Text);

            if (result == null)
            {
                await firebaseHelper.AddUser(txtUsername.Text, txtPassword.Text, txtEmail.Text);
                await DisplayAlert("Success", "User Added Successfully", "OK");

                await Navigation.PushAsync(new Login());
            }
            else
            {
                await DisplayAlert("Fail", "This username is not available", "OK");

                txtUsername.Text = string.Empty;
                //txtId.Text = string.Empty;
                // txtUsername.Text = string.Empty;
                // txtPassword.Text = string.Empty;
                //txtEmail.Text = string.Empty;
                // var allUsers = await firebaseHelper.GetAllUsers();
                //lstUsers.ItemsSource = allUsers;
            }
        }
Ejemplo n.º 14
0
        private async void SignUp()
        {
            //call AddUser function which we define in Firebase helper class
            var user = await FirebaseHelper.AddUser(Email, Password, StudentID, FirstName, LastName, CarMake, CarModel,
                                                    CarYear, CarColor, LicenseNumber);

            //AddUser return true if data insert successfuly
            if (user)
            {
                await App.Current.MainPage.DisplayAlert("SignUp Success", "", "Ok");

                //Navigate to Wellcom page after successfuly SignUp
                //pass user email to welcom page
                SignEnable = true;
                Truefalse  = false;
                await App.Current.MainPage.Navigation.PushAsync(new LoginPage());
            }
            else
            {
                SignEnable = true;
                Truefalse  = false;
                await App.Current.MainPage.DisplayAlert("Error", "SignUp Fail", "OK");
            }
        }
Ejemplo n.º 15
0
        async private void registerButton_Clicked(object sender, EventArgs e)
        {
            bool formValid           = true;
            var  userEmail           = email.Text ?? "";
            var  userPassword        = password.Text ?? "";
            var  userUsername        = username.Text ?? "";
            var  userPhoneNumber     = phoneNumber.Text ?? "";
            var  userReenterPassword = reenterPassword.Text ?? "";

            // Form validation

            // Validate email
            var emailPattern = @"^([a-zA-Z0-9_\-\.]+)@([a-zA-Z0-9_\-\.]+)\.([a-zA-Z]{2,5})$";

            if (!Regex.IsMatch(userEmail, emailPattern))
            {
                emailErrorLabel.Text      = "Please enter a valid email address";
                emailErrorLabel.IsVisible = true;
                formValid = false;
            }
            else
            {
                emailErrorLabel.IsVisible = false;
            }

            // validate phone number
            var phoneNumberPattern = @"[6][0][1][0-9]{8,9}$";

            if (!Regex.IsMatch(userPhoneNumber, phoneNumberPattern))
            {
                phoneNumberErrorLabel.Text      = "Please enter a valid phone number eg: 60123456789";
                phoneNumberErrorLabel.IsVisible = true;
                formValid = false;
            }
            else
            {
                phoneNumberErrorLabel.IsVisible = false;
            }

            // validate password
            var passwordPattern = @"^.{6,}$";

            if (!Regex.IsMatch(userPassword, passwordPattern))
            {
                passwordErrorLabel.Text      = "Password must be of minimum 6 characters";
                passwordErrorLabel.IsVisible = true;
                formValid = false;
            }
            else
            {
                passwordErrorLabel.IsVisible = false;
            }

            // validate password matching


            if (userPassword != userReenterPassword)
            {
                repasswordErrorLabel.Text      = "Passwords do not match";
                repasswordErrorLabel.IsVisible = true;
                formValid = false;
            }
            else
            {
                repasswordErrorLabel.IsVisible = false;
            }

            // validate username
            if (userUsername == string.Empty)
            {
                usernameErrorLabel.Text      = "Username cannot be empty";
                usernameErrorLabel.IsVisible = true;
                formValid = false;
            }
            else
            {
                usernameErrorLabel.IsVisible = false;
            }

            if (formValid)
            {
                loader.IsRunning = true;
                loader.IsVisible = true;
                // Create User Account with Firebase Auth & Add a User record to Realtime DB
                try
                {
                    // string getToken = auth.FirebaseToken;
                    await firebaseHelper.CreateUserWithEmailAndPasswordAsync(userEmail, userPassword);

                    await firebaseHelper.AddUser(userEmail, userUsername, userPhoneNumber);

                    loader.IsRunning = false;
                    loader.IsVisible = false;
                    await DisplayAlert("Alert", "Registration Successful", "OK");

                    App.Current.MainPage = new MasterDetailPageKitaBantu();
                    // await App.Current.MainPage.DisplayAlert("Alert", getToken, "OK");
                }
                catch (Exception ex)
                {
                    loader.IsRunning = false;
                    loader.IsVisible = false;
                    await App.Current.MainPage.DisplayAlert("Alert", ex.Message, "OK");
                }
            }
        }
Ejemplo n.º 16
0
        //Add user to Realtime database
        private async void AddtoRealtime()
        {
            int.TryParse(input_age.Text, out num);

            await fh.AddUser(input_email.Text, input_pwd.Text, input_username.Text, num, "Picture", input_favInstrument.Text, input_bio.Text, input_youlink.Text, ye, nay);
        }