예제 #1
0
        private async void Sign_up(object sender, RoutedEventArgs e)
        {
            if (ConnectionUtil.CheckConnection())
            {
                client = new FireSharp.FirebaseClient(main.config);
                FirebaseResponse firebaseResponse = await client.GetAsync("Admin/" + signupName.Text);

                Admin foundAdmin = firebaseResponse.ResultAs <Admin>();
                if (foundAdmin == null)
                {
                    Admin admin = new Admin
                    {
                        Email    = signupEmail.Text.ToString(),
                        Password = Encrypt.GetShaData(signupPassword.Password.ToString()),
                        Name     = signupName.Text.ToString()
                    };

                    SetResponse response = await client.SetAsync("Admin/" + signupName.Text, admin);

                    Admin adminn = response.ResultAs <Admin>();
                    MessageBox.Show(adminn.Name);
                }
                else
                {
                    MessageBox.Show("Username taken");
                }
            }
            else
            {
                MessageBox.Show("error");
            }
        }
예제 #2
0
        private async void Login(object sender, RoutedEventArgs e)
        {
            if (ConnectionUtil.CheckConnection())
            {
                client = new FireSharp.FirebaseClient(config);
                FirebaseResponse firebaseResponse = await client.GetAsync("Admin/" + Username.Text);

                Admin admin = firebaseResponse.ResultAs <Admin>();
                if (admin != null)
                {
                    if (Encrypt.GetShaData(password.Password).Equals(admin.Password))
                    {
                        this.Hide();
                        AdminWindow adminWindow = new AdminWindow();
                        adminWindow.Show();
                    }
                    else
                    {
                        Error.Visibility = Visibility.Visible;
                        Error.Text       = "Incorrect password";
                    }
                }
            }
            else
            {
                Error.Visibility = Visibility.Visible;
                Error.Text       = "Connection error";

                /* this.Hide();
                 * Form1 win = new Form1();
                 * win.Show()*/;

                /*this.Hide();
                 *
                 * AdminWindow admin = new AdminWindow();
                 * admin.Show();*/
            }
        }