Пример #1
0
    //Log user in
    public void Login()
    {
        //Get entered username and password
        string username  = UsernameBox.GetComponent <InputField>().text;
        string password  = PasswordBox.GetComponent <InputField>().text;
        string bonusCode = BonusCodeBox.GetComponent <InputField>().text;
        //Attempt user login
        int status = DatabaseManager.GetComponent <NetworkManager>().PlayerLogin(username, password, bonusCode);

        //Log user in if successful (status == 0)
        if (status == 0)
        {
            StartGame();
            return;
        }
        //Else print error code
        //Get error message
        if (status == -1)    //Username not found
        {
            ErrorMessage.GetComponent <Text>().text  = "Error: Username not found";
            ErrorMessage.GetComponent <Text>().color = Color.red;
        }
        else if (status == -2) //Password incorrect
        {
            ErrorMessage.GetComponent <Text>().text  = "Error: Password incorrect";
            ErrorMessage.GetComponent <Text>().color = Color.red;
        }
    }
        private void LoginButton_Click(object sender, EventArgs e)
        {
            try
            {
                if (_controller.LogIn(UsernameBox.Text, PasswordBox.Text))
                {
                    var mainWindow = new TransportWindow(_controller);
                    Hide();
                    mainWindow.FormClosed += (a, b) => Show();
                    mainWindow.Show();
                }
                else
                {
                    MessageBox.Show(@"Invalid username/password", @"Login Error", MessageBoxButtons.OK,
                                    MessageBoxIcon.Error);
                }

                UsernameBox.Clear();
                PasswordBox.Clear();
            }
            catch (Exception error)
            {
                MessageBox.Show(error.Message, @"Login Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Пример #3
0
        public void Clear()
        {
            UsernameBox.Clear();
            PasswordBox.Clear();

            ErrorLabel.Text = "";
        }
Пример #4
0
        private bool Validacija()
        {
            if (string.IsNullOrWhiteSpace(UsernameBox.Text))
            {
                MessageBox.Show("Username polje mora biti popunjeno");
                UsernameBox.Focus();
                return(false);
            }

            if (string.IsNullOrWhiteSpace(PasswordBox.Text))
            {
                MessageBox.Show("Password polje mora biti popunjeno");
                PasswordBox.Focus();
                return(false);
            }

            if (Combo.SelectedIndex < 0)
            {
                MessageBox.Show("Status polje mora biti izabrano");
                Combo.Focus();
                return(false);
            }


            return(true);
        }
Пример #5
0
        private void LoadUserSettings()
        {
            string user = settings.Get("Credentials", "Username");
            string pswd = settings.Get("Credentials", "Password");

            UsernameBox.Select(); //Activate it

            if (user.Length <= 0)
            {
                return;
            }
            UsernameBox.Text = user;

            if (pswd.Length <= 0)
            {
                return;
            }
            string data = Register.GetKeyData("PasswordLength", "Launcher");
            string test = string.Empty;
            int    length;

            if (string.IsNullOrEmpty(data) || !int.TryParse(data, out length))
            {
                return;
            }

            for (int c = 0; c < length; c++)
            {
                test += "*";
            }
            PasswordBox.Text = test;
            pswdTextChanged  = false;

            RememberPwd.Checked = true;
        }
Пример #6
0
        public LoginWindow()
        {
            InitializeComponent();

            UsernameBox.Focus();
            Util.CreateUuid();
        }
Пример #7
0
        private void OKButton_Click(object sender, RoutedEventArgs e)
        {
            if (AccountText == null || AccountText.Length == 0)
            {
                MessageBox.Show("Account login required!");
                UsernameBox.Focus();
                return;
            }
            if (PasswordText == null || PasswordText.Length == 0)
            {
                MessageBox.Show("Account password required!");
                PasswordBox.Focus();
                return;
            }

            if (autoLogCheckBox.IsChecked == true)
            {
                AutoLogAccountIndex = true;
            }
            else
            {
                AutoLogAccountIndex = false;
            }

            DialogResult = true;
        }
Пример #8
0
 void LoginView_Loaded(object sender, RoutedEventArgs e)
 {
     if (ViewModel != null)
     {
         ViewModel.LoadStocks();
         UsernameBox.Focus();
     }
 }
 //Clear the username box
 private void TextBox_MouseEnter(object sender, MouseEventArgs e)
 {
     if (this.mouseEnterUsername == false)
     {
         UsernameBox.Clear();
         this.mouseEnterUsername = true;
     }
 }
Пример #10
0
 private void usernameLostFocus(object sender, RoutedEventArgs e)
 {
     if (UsernameBox.Text == "")
     {
         user.Username = "******";
         UsernameBox.GetBindingExpression(TextBox.TextProperty).UpdateTarget();
     }
 }
Пример #11
0
        private void button2_Click(object sender, EventArgs e)
        {
            ReadRequest req = new ReadRequest("got back from server woo");

            string temp = client.SendRequest <string>(req);

            UsernameBox.AppendText(Environment.NewLine + temp);
        }
Пример #12
0
        public RegisterForm()
        {
            InitializeComponent();

            //Activate our box control
            UsernameBox.Select();
            AcceptButton = RegisterButton;
        }
Пример #13
0
        public RegisterForm(IniFile Settings)
        {
            InitializeComponent();
            settings = Settings;

            //Activate our box control
            UsernameBox.Select();
            AcceptButton = RegisterButton;
        }
Пример #14
0
 private void Login()
 {
     loggedIn = true;
     UsernameBox.Hide();
     PasswordBox.Hide();
     Login_Button.Hide();
     BrugerLabel.Hide();
     KodeLabel.Hide();
     cridentials.Hide();
 }
Пример #15
0
 // Constructor
 public MbConnectView()
 {
     InitializeComponent();
     Loaded += (sender, args) =>
     {
         if (ApplicationBar != null && ApplicationBar.Mode == ApplicationBarMode.Default)
         {
             UsernameBox.Focus();
         }
     };
 }
Пример #16
0
        private void RegisterButton_Click(object sender, RoutedEventArgs e)
        {
            string username = UsernameBox.Text;
            string password = HashAndSalt(PasswordBox.Password);

            if (username.Length == 0 && PasswordBox.Password.Length == 0)
            {
                ErrorText.Text = "To register, type a username and password in the boxes above.";
                UsernameBox.SelectAll();
                UsernameBox.Focus();
            }
            else if (username.Length == 0)
            {
                ErrorText.Text = "Username cannot be blank.";
                UsernameBox.SelectAll();
                UsernameBox.Focus();
            }
            else if (PasswordBox.Password.Length < 8)
            {
                ErrorText.Text = "Password must be at least 8 characters.";
                PasswordBox.SelectAll();
                PasswordBox.Focus();
            }
            else if (!(new Regex(@"^[a-zA-Z0-9]*$").IsMatch(username)))
            {
                ErrorText.Text = "Usernames must be alphanumeric.";
                UsernameBox.SelectAll();
                UsernameBox.Focus();
            }
            else
            {
                var addUserResult = Operations.Insert(
                    string.Format(
                        "INSERT INTO users(username, password) VALUES (\"{0}\", \"{1}\");",
                        username,
                        password));
                int code = addUserResult;
                if (code == 0)
                {
                    ErrorText.Text = "Registration successful! Please login to access application.";
                }
                else if (code == 1062)
                {
                    ErrorText.Text = "Username taken.";
                }
                else
                {
                    ErrorText.Text = "Error registering user. (" + code + ")";
                }
            }
        }
Пример #17
0
        public UserLoginControl()
        {
            InitializeComponent();

            // Clear the password box when the window is closed
            this.IsVisibleChanged += (sender, e) =>
            {
                PasswordText.Clear();
            };
            UsernameBox.Focus();


            DataContext = IoC.CreateInstance <UserLoginControlViewModel>();
        }
Пример #18
0
        private void LoginBTN(object sender, RoutedEventArgs e)
        {
            bool EverythingFine = true;

            if (String.IsNullOrEmpty(UsernameBox.Text))
            {
                UsernameBox.GetBindingExpression(TextBox.TextProperty);
                ValidationError validationError = new ValidationError(new NotEmptyValidationRule(), UsernameBox.GetBindingExpression(TextBox.TextProperty));
                validationError.ErrorContent = "Field is required.";

                Validation.MarkInvalid(
                    UsernameBox.GetBindingExpression(TextBox.TextProperty),
                    validationError);
                EverythingFine = false;
            }
            else
            {
                Validation.ClearInvalid(UsernameBox.GetBindingExpression(TextBox.TextProperty));
            }
            if (String.IsNullOrEmpty(PasswordBox.Password))
            {
                PasswordBox.GetBindingExpression(TextBox.TextProperty);
                ValidationError validationError = new ValidationError(new NotEmptyValidationRule(), PasswordBox.GetBindingExpression(PasswordBox.DataContextProperty));
                validationError.ErrorContent = "Field is required.";

                Validation.MarkInvalid(
                    PasswordBox.GetBindingExpression(PasswordBox.DataContextProperty),
                    validationError);
                EverythingFine = false;
            }
            else if (PasswordBox.Password.Length < 8)
            {
                PasswordBox.GetBindingExpression(TextBox.TextProperty);
                ValidationError validationError = new ValidationError(new NotEmptyValidationRule(), PasswordBox.GetBindingExpression(PasswordBox.DataContextProperty));
                validationError.ErrorContent = "At least 8 characters.";

                Validation.MarkInvalid(
                    PasswordBox.GetBindingExpression(PasswordBox.DataContextProperty),
                    validationError);
                EverythingFine = false;
            }
            else
            {
                Validation.ClearInvalid(PasswordBox.GetBindingExpression(PasswordBox.DataContextProperty));
            }
            if (EverythingFine)
            {
                //TODO: Sign In Using Communicator
            }
        }
Пример #19
0
        ///////////////////////////////////////
        //-- Main Page - Program Interface --//
        ///////////////////////////////////////

        private void LayawaySystem_Load(object sender, EventArgs e)
        {
            //Fills Data Grids with information from the appropriate database table

            this.stockTableAdapter1.Fill(this.layawayDBDataSet5.Stock);

            // this.stockTableAdapter.Fill(this.layawayDBDataSet4.Stock);

            this.customerTableAdapter2.Fill(this.layawayDBDataSet3.Customer);

            this.locationTableAdapter.Fill(this.layawayDBDataSet1.Location);

            UsernameBox.Focus();
        }
Пример #20
0
 public Registration()
 {
     InitializeComponent();
     db = Database.getInstanece();
     user.Username = "******";
     user.Email = "Email";
     Binding b = new Binding();
     b.Source = user;
     b.Path = new PropertyPath("Username");
     b.Mode = BindingMode.TwoWay;
     UsernameBox.SetBinding(TextBox.TextProperty, b);
     b = new Binding();
     b.Source = user;
     b.Path = new PropertyPath("Email");
     b.Mode = BindingMode.TwoWay;
     EmailBox.SetBinding(TextBox.TextProperty, b);
 }
Пример #21
0
 /// <summary>
 /// Will auto fill the username and password if the person has already filled it out before clicking register
 /// </summary>
 public void AutoFill(string username, string password)
 {
     UsernameBox.Text = username;
     PasswordBox.Text = password;
     //Lets activate the correct box control
     if (string.IsNullOrEmpty(username))
     {
         UsernameBox.Select();
     }
     else if (string.IsNullOrEmpty(password))
     {
         PasswordBox.Select();
     }
     else
     {
         EmailBox.Select();
     }
 }
Пример #22
0
 private void ConfirmButton_Click(object sender, RoutedEventArgs e)
 {
     if (string.IsNullOrEmpty(UsernameBox.Text.Trim()))
     {
         NotificationLabel.ShowError("Please fill in username !");
         UsernameBox.Focus();
     }
     else if (string.IsNullOrEmpty(PasswordBox.Password))
     {
         NotificationLabel.ShowError("Please type in new Password !");
         PasswordBox.Focus();
     }
     else if (string.IsNullOrEmpty(RepeatPasswordBox.Password) ||
              !RepeatPasswordBox.Password.Equals(PasswordBox.Password))
     {
         NotificationLabel.ShowError("Please Confirm new Password");
         RepeatPasswordBox.Focus();
     }
     else
     {
         UserDAO dao = new UserDAO();
         try
         {
             User user = dao.GetUsers(username: UsernameBox.Text.Trim()).First();
             user.Password = PasswordBox.Password;
             dao.Update(user);
             NotificationLabel.ShowSuccess("Password changed successfully");
         }
         catch (System.InvalidOperationException ie)
         {
             DebugLog.WriteLine(ie);
             NotificationLabel.ShowError("Username does not exist !");
         }
         catch (Exception ex)
         {
             DebugLog.WriteLine(ex);
             NotificationLabel.ShowError("Could not update user !");
         }
     }
 }
Пример #23
0
        private void LoadUserSettings()
        {
            string user = GameSettings.Credentials._username;
            string pswd = GameSettings.Credentials._password;


            UsernameBox.Select(); //Activate it

            if (user.Length <= 0)
            {
                return;
            }
            UsernameBox.Text = user;

            if (pswd.Length <= 0)
            {
                return;
            }
            string data = GameSettings.Credentials._passwordLength;
            string test = string.Empty;
            int    length;

            if (string.IsNullOrEmpty(data) || !int.TryParse(data, out length))
            {
                return;
            }

            for (int c = 0; c < length; c++)
            {
                test += "*";
            }
            PasswordBox.Text = test;
            pswdTextChanged  = false;

            RememberPwd.Checked = true;
        }
        //Check login than open HomePage
        private void LoginButton_Click(object sender, RoutedEventArgs e)
        {
            var username = UsernameBox.Text;
            var password = PasswordBox.Password;

            sc.LoginToServer(username, password);

            while (!sc.HasReceivedLoginFeedback())
            {
                Thread.Sleep(5);
            }

            if (sc.IsLoggedIn())
            {
                Hide();
                var layout = new Layout(username, sc);
                layout.Show();
            }
            else
            {
                UsernameBox.Clear();
                PasswordBox.Clear();
            }
        }
Пример #25
0
        private void LoginBTN_Clicked(object sender, RoutedEventArgs e)
        {
            Button btn = sender as Button;

            MaterialDesignThemes.Wpf.ButtonProgressAssist.SetIsIndeterminate(btn, true);
            MaterialDesignThemes.Wpf.ButtonProgressAssist.SetValue(btn, -1);
            MaterialDesignThemes.Wpf.ButtonProgressAssist.SetIsIndicatorVisible(btn, true);
            btn.IsEnabled       = false;
            SignupBTN.IsEnabled = false;
            bool EverythingFine = true;

            if (String.IsNullOrEmpty(UsernameBox.Text))
            {
                UsernameBox.GetBindingExpression(TextBox.TextProperty);
                ValidationError validationError = new ValidationError(new NotEmptyValidationRule(), UsernameBox.GetBindingExpression(TextBox.TextProperty));
                validationError.ErrorContent = "Field is required.";

                Validation.MarkInvalid(
                    UsernameBox.GetBindingExpression(TextBox.TextProperty),
                    validationError);
                EverythingFine = false;
            }
            else
            {
                Validation.ClearInvalid(UsernameBox.GetBindingExpression(TextBox.TextProperty));
            }
            if (String.IsNullOrEmpty(PasswordBox.Password))
            {
                PasswordBox.GetBindingExpression(TextBox.TextProperty);
                ValidationError validationError = new ValidationError(new NotEmptyValidationRule(), PasswordBox.GetBindingExpression(PasswordBox.DataContextProperty));
                validationError.ErrorContent = "Field is required.";

                Validation.MarkInvalid(
                    PasswordBox.GetBindingExpression(PasswordBox.DataContextProperty),
                    validationError);
                EverythingFine = false;
            }
            else if (PasswordBox.Password.Length < 1)
            {
                PasswordBox.GetBindingExpression(TextBox.TextProperty);
                ValidationError validationError = new ValidationError(new NotEmptyValidationRule(), PasswordBox.GetBindingExpression(PasswordBox.DataContextProperty));
                validationError.ErrorContent = "At least 8 characters.";

                Validation.MarkInvalid(
                    PasswordBox.GetBindingExpression(PasswordBox.DataContextProperty),
                    validationError);
                EverythingFine = false;
            }
            else
            {
                Validation.ClearInvalid(PasswordBox.GetBindingExpression(PasswordBox.DataContextProperty));
            }
            if (EverythingFine)
            {
                LoginRequest loginRequest = new LoginRequest();
                loginRequest.username = UsernameBox.Text;
                loginRequest.password = PasswordBox.Password;

                app.communicator.SocketSendReceive(JsonSerializer.serializeRequest(loginRequest, Constants.LOGIN_REQUEST_CODE)).ContinueWith(task =>
                {
                    ResponseInfo response       = task.Result;
                    LoginResponse loginResponse = JsonDeserializer.deserializeResponse <LoginResponse>(response.buffer);
                    switch (loginResponse.status)
                    {
                    case Constants.LOGIN_SUCCESS:
                        MyMessageQueue.Enqueue("Sign in Successfully!");
                        this.Dispatcher.Invoke(() =>
                        {
                            app.username         = UsernameBox.Text;
                            NavigationService ns = NavigationService.GetNavigationService(this);
                            ns.Navigate(new Uri("Menu.xaml", UriKind.Relative));
                        });
                        break;

                    case Constants.LOGIN_INCORRECT_PASSWORD:
                        MyMessageQueue.Enqueue("Incorrect password.");
                        break;

                    case Constants.LOGIN_USERNAME_NOT_EXIST:
                        MyMessageQueue.Enqueue("Username not exist.");
                        break;

                    case Constants.LOGIN_UNEXPECTED_ERR:
                        MyMessageQueue.Enqueue("There was an unexpected error.");
                        break;

                    case Constants.LOGIN_ALREADY_ONLINE:
                        MyMessageQueue.Enqueue("This Username is already online.");
                        break;
                    }
                    this.Dispatcher.Invoke(() =>
                    {
                        ButtonProgressAssist.SetIsIndeterminate(btn, false);
                        ButtonProgressAssist.SetIsIndicatorVisible(btn, false);
                        btn.IsEnabled       = true;
                        SignupBTN.IsEnabled = true;
                    });
                });
            }
            else
            {
                MaterialDesignThemes.Wpf.ButtonProgressAssist.SetIsIndeterminate(btn, false);
                MaterialDesignThemes.Wpf.ButtonProgressAssist.SetIsIndicatorVisible(btn, false);
                btn.IsEnabled       = true;
                SignupBTN.IsEnabled = true;
            }
        }
Пример #26
0
 private void UsernamePlaceholder_GotFocus(object sender, RoutedEventArgs e)
 {
     UsernamePlaceholder.Visibility = Visibility.Hidden;
     UsernameBox.Focus();
 }
Пример #27
0
 private void ForgotPasswordModule_Load(object sender, EventArgs e)
 {
     UsernameBox.Focus();
     ServerInfo.mySQLConnect.Open();
 }
 public CreateUserPage(IUserController userController)
 {
     InitializeComponent();
     UsernameBox.Focus();
 }
Пример #29
0
 public MainWindow()
 {
     InitializeComponent();
     UsernameBox.Focus();
 }
Пример #30
0
 public Login()
 {
     InitializeComponent();
     UsernameBox.Focus();
     this.PreviewKeyDown += new KeyEventHandler(HandleEsc);
 }