Exemplo n.º 1
0
 void CreateAccount()
 {
     sql.LoadTable($"select * from Users where Email='{createEmail.Text.Trim()}';", ref dt);
     if (dt.Rows.Count == 0)
     {
         string query = $"insert into Users values('{createUser.Text.Trim()}', '{createEmail.Text.Trim()}', '{createPass.Password.Trim()}')";
         sql.ExecuteQuery(query);
         MsgBoxLogin msgBox = new MsgBoxLogin("succ", "Account created successfully", "Cool")
         {
             Owner  = this,
             Width  = ActualWidth,
             Height = ActualHeight
         };
         msgBox.ShowDialog();
         CreateAccGrid.Visibility       = Visibility.Collapsed;
         CreateAccStage2Grid.Visibility = Visibility.Visible;
     }
     else
     {
         MsgBoxLogin msgBox = new MsgBoxLogin("error", "Account already exists", "Login")
         {
             Owner  = this,
             Width  = ActualWidth,
             Height = ActualHeight
         };
         msgBox.ShowDialog();
         CreateAccGrid.Visibility = Visibility.Collapsed;
         LoginAccGrid.Visibility  = Visibility.Visible;
         loginPass.Password       = createPass.Password.Trim();
         loginUserEmail.Text      = createEmail.Text.Trim();
     }
 }
Exemplo n.º 2
0
        void LoginAccount()
        {
            sql.LoadTable($"select * from Users where Email='{loginUserEmail.Text.Trim()}';", ref dt);
            if (dt.Rows.Count == 0)
            {
                MsgBoxLogin msgBox = new MsgBoxLogin("error", "Can't find an account associated with this email id", "Okay")
                {
                    Owner  = this,
                    Width  = ActualWidth,
                    Height = ActualHeight
                };
                msgBox.ShowDialog();
            }
            else
            {
                if (loginUserEmail.Text.Trim() == dt.Rows[0][1].ToString() && loginPass.Password.Trim() == dt.Rows[0][2].ToString())
                {
                    if (RemMeChck.IsChecked == true)
                    {
                        Properties.Settings.Default.email = loginUserEmail.Text.Trim();
                        Properties.Settings.Default.pass  = loginPass.Password.Trim();
                        Properties.Settings.Default.Save();
                    }
                    else
                    {
                        Properties.Settings.Default.Reset();
                    }

                    Properties.Settings.Default.CurrentUser = loginUserEmail.Text.Trim();
                    Properties.Settings.Default.Save();

                    MainWindow mainWindow = new MainWindow();
                    mainWindow.Show();
                    Close();
                }
                else
                {
                    MsgBoxLogin msgBox = new MsgBoxLogin("error", "Password and username doesn't match", "Okay")
                    {
                        Owner  = this,
                        Width  = ActualWidth,
                        Height = ActualHeight
                    };
                    msgBox.ShowDialog();
                }
            }
        }
Exemplo n.º 3
0
        async void VerifyFtpServer()
        {
            ConnectionPrep();
            FtpClient client = new FtpClient(ftpHost.Text.Trim());

            client.Credentials = new NetworkCredential(ftpUser.Text.Trim(), ftpPass.Password.Trim());
            try
            {
                await client.ConnectAsync();
            }
            catch (FtpAuthenticationException)
            {
                MsgBoxLogin msgBox = new MsgBoxLogin("error", "Please check the username or password", "Okay")
                {
                    Owner  = this,
                    Width  = ActualWidth,
                    Height = ActualHeight
                };
                msgBox.ShowDialog();
                ResetFtpPage();
                return;
            }
            catch (SocketException)
            {
                MsgBoxLogin msgBox = new MsgBoxLogin("error", "Please enter a valid host address", "Okay")
                {
                    Owner  = this,
                    Width  = ActualWidth,
                    Height = ActualHeight
                };
                msgBox.ShowDialog();
                ResetFtpPage();
                return;
            }

            ConnectionSucces();
        }
Exemplo n.º 4
0
        async void VerifyAnonFtpServer()
        {
            ConnectionPrep();
            FtpClient client = new FtpClient(ftpHost.Text.Trim());

            try
            {
                await client.ConnectAsync();
            }
            catch (FtpAuthenticationException)
            {
                MsgBoxLogin msgBox = new MsgBoxLogin("error", "Host doesn't allow anonymous login", "Okay")
                {
                    Owner  = this,
                    Width  = ActualWidth,
                    Height = ActualHeight
                };
                msgBox.ShowDialog();
                ResetFtpPage();
                return;
            }
            catch (SocketException)
            {
                MsgBoxLogin msgBox = new MsgBoxLogin("error", "Please enter a valid host address", "Okay")
                {
                    Owner  = this,
                    Width  = ActualWidth,
                    Height = ActualHeight
                };
                msgBox.ShowDialog();
                ResetFtpPage();
                return;
            }

            ConnectionSucces();
        }
Exemplo n.º 5
0
        //MainWindow mainWindow = Application.Current.Windows.OfType<MainWindow>().FirstOrDefault();

        private void Validator(string type)
        {
            if (type == "create")
            {
                if (createUser.Text.Trim() == "" || createEmail.Text.Trim() == "" || createPass.Password.Trim() == "" || createPassRep.Password.Trim() == "")
                {
                    MsgBoxLogin msgBox = new MsgBoxLogin("error", "Please fill in all necessary fields", "Try again")
                    {
                        Owner  = this,
                        Width  = ActualWidth,
                        Height = ActualHeight
                    };
                    msgBox.ShowDialog();
                }
                else if (createPass.Password.Trim() != createPassRep.Password.Trim())
                {
                    MsgBoxLogin msgBox = new MsgBoxLogin("error", "Password don't match", "Okay")
                    {
                        Owner  = this,
                        Width  = ActualWidth,
                        Height = ActualHeight
                    };
                    msgBox.ShowDialog();
                }
                else if (createEmail.Text.Trim() == "")
                {
                    MsgBoxLogin msgBox = new MsgBoxLogin("error", "Email id is neccessary", "Got it")
                    {
                        Owner  = this,
                        Width  = ActualWidth,
                        Height = ActualHeight
                    };
                    msgBox.ShowDialog();
                }
                else if (!Regex.IsMatch(createEmail.Text, @"^[a-zA-Z][\w\.-]*[a-zA-Z0-9]@[a-zA-Z0-9][\w\.-]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z]$"))
                {
                    MsgBoxLogin msgBox = new MsgBoxLogin("error", "Please enter a valid mail-id", "Okay")
                    {
                        Owner  = this,
                        Width  = ActualWidth,
                        Height = ActualHeight
                    };
                    msgBox.ShowDialog();
                }
                else
                {
                    CreateAccount();
                }
            }
            else if (type == "ftp")
            {
                if (ftpHost.Text.Trim() == "")
                {
                    MsgBoxLogin msgBox = new MsgBoxLogin("error", "Please enter your FTP server address", "Okay")
                    {
                        Owner  = this,
                        Width  = ActualWidth,
                        Height = ActualHeight
                    };
                    msgBox.ShowDialog();
                }
                else if (ftpUser.Text.Trim() == "" || ftpUser.Text.Trim() == "")
                {
                    VerifyAnonFtpServer();
                }
                else
                {
                    VerifyFtpServer();
                }
            }
            else if (type == "login")
            {
                if (loginUserEmail.Text.Trim() == "" || loginPass.Password.Trim() == "")
                {
                    MsgBoxLogin msgBox = new MsgBoxLogin("error", "Please enter your username and password", "Try again")
                    {
                        Owner  = this,
                        Width  = ActualWidth,
                        Height = ActualHeight
                    };
                    msgBox.ShowDialog();
                }
                else if (!Regex.IsMatch(loginUserEmail.Text, @"^[a-zA-Z][\w\.-]*[a-zA-Z0-9]@[a-zA-Z0-9][\w\.-]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z]$"))
                {
                    MsgBoxLogin msgBox = new MsgBoxLogin("error", "Please enter a valid mail-id", "Okay")
                    {
                        Owner  = this,
                        Width  = ActualWidth,
                        Height = ActualHeight
                    };
                    msgBox.ShowDialog();
                }
                else
                {
                    LoginAccount();
                }
            }
        }