Example #1
0
 private void Button_Click(object sender, RoutedEventArgs e)
 {
     if (txtbox_VereficationCode.Text == client.GetVerificationCodeFromEmail(client.GetUserByLogin(login).Email).ToString())
     {
         this.DialogResult = true;
         this.Close();
     }
     else
     {
         MsgBox msg = new MsgBox("Error!", "Wrong code");
         msg.Show();
     }
 }
Example #2
0
        private void ButtonLogin_Click(object sender, RoutedEventArgs e)
        {
            Task.Run(() => { this.client.Request(); });
            string login    = logTxtBox_login.Text;
            string password = passwdbox.Password;

            buttonLogin.Content   = pgLoading;
            buttonLogin.IsEnabled = false;
            Task.Run(() =>
            {
                if (client.IsExistsUserByLoginPassword(login, password))
                {
                    client.Connect(login, password); //isActive change
                    Application.Current.Dispatcher.Invoke(() =>
                    {
                        UserDTO user = new UserDTO();
                        user         = client.GetUserByLogin(logTxtBox_login.Text);
                        logginedUsers.Add(user);
                        if (rememberMe.IsChecked == true)
                        {
                            Save(logginedUsers);
                        }
                        MainMenuZaolis mnz = new MainMenuZaolis(logginedUsers, client);
                        mnz.Show();
                        this.Close();
                    });
                }
                else
                {
                    Application.Current.Dispatcher.Invoke(() =>
                    {
                        buttonLogin.Content   = "LOGIN";
                        buttonLogin.IsEnabled = true;
                        ShowMsg("Error!", "There is no user with such login or password");
                    });
                }
            });
        }
Example #3
0
        public string this[string columnName]
        {
            get
            {
                string error = string.Empty;
                if (Login != null)
                {
                    switch (columnName)
                    {
                    case nameof(Login):
                        var login_reg = new Regex(@"^\w{6,16}$");
                        if (Login != null && !login_reg.IsMatch(Login))
                        {
                            error        = "Login length should be between 6 and 16 characters. Without special characters.";
                            login_valide = false;
                        }
                        else
                        {
                            if (client.GetUserByLogin(Login) != null)
                            {
                                error        = "Such a user already exists!";
                                login_valide = false;
                            }
                            else
                            {
                                login_valide = true;
                            }
                        }
                        OnPropertyChanged(nameof(isAllValide));
                        break;

                    case nameof(Email):
                    {
                        var email_reg = new Regex(@"^[a-z,A-Z,0-9](\.?[a-z,A-Z,0-9]){5,}@[a-z]{2,}\.(com|net|ua|ru)$");
                        if (Email != null && !email_reg.IsMatch(Email))
                        {
                            error        = "Invalid email specified.";
                            email_valide = false;
                        }
                        else
                        {
                            if (client.IsExistsUserByEmail(Email))
                            {
                                error        = "A user with this email already exists!";
                                email_valide = false;
                            }
                            else
                            {
                                email_valide = true;
                            }
                        }
                        OnPropertyChanged(nameof(isAllValide));
                        break;
                    }

                    case nameof(Passwd):
                        if (Passwd != null && Passwd.Length < 5)
                        {
                            error         = "Password must be at least 5 characters long.";
                            passwd_valide = false;
                        }
                        else
                        {
                            passwd_valide = true;
                        }
                        OnPropertyChanged(nameof(isAllValide));
                        break;

                    case nameof(ConfirmPasswd):
                        if (ConfirmPasswd != null && ConfirmPasswd != Passwd)
                        {
                            error = "Passwords do not match";
                            confirm_pass_valide = false;
                        }
                        else
                        {
                            confirm_pass_valide = true;
                        }
                        OnPropertyChanged(nameof(isAllValide));
                        break;

                    default:
                        break;
                    }
                }
                return(error);
            }
        }