private void Register(object obj) { if (obj == null) { return; } var value = (object[])obj; TextBox username = (TextBox)value[0]; PasswordBox boxPass = (PasswordBox)value[1]; PasswordBox boxRePass = (PasswordBox)value[2]; User user = usersList.Find(x => x.UserName.ToString() == username.Text.ToString()); if (user == null) { user = new User(); Password = boxPass.Password; user.Passw = Password; user.UserName = username.Text.ToString(); _ctx.Users.Add(user); _ctx.SaveChangesAsync(); var Main = new MainWindow(); Main.Show(); CloseWindow(); } else { MessageBox.Show("Username already taken."); username.Clear(); boxPass.Clear(); boxRePass.Clear(); } }
/// <summary> /// Eventmetode for loginknapp /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void buttonLogin_Click(object sender, EventArgs e) { if (!_brukerNavnValidated || !_passordValidated) { return; } if (_dbConnect.CheckPassword(_finalBrukernavn, _finalPassord)) { SpillerNavn = _finalBrukernavn; SpillerID = _dbConnect.GetPlayerId(_finalBrukernavn); SpillerHighScore = _dbConnect.GetPersonalBest(SpillerID); // AllHighScore = _dbConnect.GetHighScores(); //Program.cs sjekker om DoRun er true, lukker så dette formet sånn at tråden kan kjøre spillet. if (!String.IsNullOrEmpty(SpillerNavn) && !String.IsNullOrEmpty(SpillerID.ToString()) && !String.IsNullOrEmpty(SpillerHighScore.ToString())) { DoRun = true; Close(); } else { errorProviderUserName.SetError(UserNameBox, "Database error"); } } else { UserNameBox.Clear(); PasswordBox.Clear(); DoRun = false; errorProviderUserName.SetError(UserNameBox, "Wrong username or password!"); } }
//Starts the login process to the application private void SubmitButton_Click(object sender, RoutedEventArgs e) { //login workflow here Worker w = new Worker(); String b = BannerBox.Text; String p = PasswordBox.Password; try { int banner = Convert.ToInt32(b); w.populate(banner); if (w.BannerID.Equals(b) && w.WorkerPassword.Equals(p)) { MainMenu m = new MainMenu(w); m.Show(); this.Hide(); } else { MessageBox.Show("Please enter a valid ID and/or Password"); BannerBox.Clear(); PasswordBox.Clear(); } } catch (Exception ex) { String et = ex.Message; MessageBox.Show("Please enter valid id and/or password"); BannerBox.Clear(); PasswordBox.Clear(); } }
private void buttonSubmit_Click(object sender, RoutedEventArgs e) { string msg; if (textBoxLogin.Text != "admin") { if ((string.IsNullOrWhiteSpace(textBoxLogin.Text)) || (string.IsNullOrWhiteSpace(PasswordBox.Password)) || (string.IsNullOrWhiteSpace(PasswordBox2.Password))) { MessageBox.Show("You have to input all fields!"); } else { if (PasswordBox.Password != PasswordBox2.Password) { MessageBox.Show("Passwords do not coincide. Try again!"); PasswordBox.Clear(); PasswordBox2.Clear(); } else { MethodsForPersons.AddPerson(textBoxLogin.Text, PasswordBox.Password, out msg); MessageBox.Show(msg); NavigationService.Navigate(new AuthorizationPage()); } } } else { MessageBox.Show("You can't use this login."); } }
/// <summary> Begins the login process. </summary> private void StartLogin() { var username = TextBox.Text; var password = PasswordBox.Password; if (string.IsNullOrWhiteSpace(username)) { Utilities.ShowValidationErrorDialog("You must enter a username."); return; } if (string.IsNullOrWhiteSpace(password)) { Utilities.ShowValidationErrorDialog("You must enter a password."); return; } PasswordBox.Clear(); try { HandshakeToken = clients.Auth.BeginLogin(new LoginCredentials { Username = username, Password = password }); } catch (FaultException fe) { Utilities.Log($"FaultException from BeginLogin: {fe}"); Utilities.ShowErrorDialog($"Login failed because \"{fe.Message}\". Please check your credentials and try again.", "Login failed"); } }
/// <summary> /// Logs into the system if the username and password match. /// </summary> /// <param name="sender">The object sender</param> /// <param name="e">The event args</param> private void loginButton_Click(object sender, EventArgs e) { Cursor = Cursors.AppStarting; if (UsernameBox.Text != "Username") { User user = DatabaseParser.GetUserByUsername(UsernameBox.Text); if (user == null || user.Password != PasswordBox.Text) { CustomMsgBox.ShowOk("Wrong username or password", "Error", CustomMsgBoxIcon.Error); // resets password with false login information if (PasswordBox.Text != "Password") { PasswordBox.Clear(); } return; } Session.LoadUser(user); this.Hide(); MainWindow main = new MainWindow(); main.ShowDialog(this); Session.LogOut(); // resets information after logout ResetInformation(); Cursor = Cursors.Arrow; } else { CustomMsgBox.ShowOk("Wrong username or password", "Error", CustomMsgBoxIcon.Error); } }
/// <summary> Completes a login process. </summary> private void ConfirmLogin() { var oneTimeUseCode = PasswordBox.Password; if (string.IsNullOrWhiteSpace(oneTimeUseCode)) { Utilities.ShowValidationErrorDialog("You must enter the authentication code."); return; } PasswordBox.Clear(); AuthToken authToken; try { authToken = clients.Auth.FinishLogin(handshake, new SecondFactor { OneTimeUseCode = oneTimeUseCode }); } catch (FaultException fe) { Utilities.Log($"Error on ConfirmLogin: {fe}"); Utilities.ShowErrorDialog($"Login failed because \"{fe.Message}\". Please check your credentials and try again.", "Login failed"); return; } HandshakeToken = null; RunUserSession(authToken); PasswordBox.Focus(); // focus back on the password, because the username will remain populated }
// clears controls after insert public static void ClearInsertUserInputs(Panel selectedPanel) { foreach (var panel in selectedPanel.Children.OfType <Panel>()) { if (panel is Panel) { foreach (var control in panel.Children.OfType <Control>()) { if (control is TextBox) { TextBox textbox = control as TextBox; textbox.Clear(); } else if (control is PasswordBox) { PasswordBox passbox = control as PasswordBox; passbox.Clear(); } else if (control is RadioButton) { RadioButton radio = control as RadioButton; radio.IsChecked = false; } } } } }
public void Login(string login, string password) { if (login.Length != 0 && password.Length != 0) { try { int id = Utils.DbHandler.ParticipantIdGet(login, password); if (id != 0) { PanelWindow mainWindow = new PanelWindow(new Participant(id, login, password)); mainWindow.Show(); this.Close(); } else { MessageBox.Show("Bad user name or password"); PasswordBox.Clear(); } } catch (Exception exception) { MessageBox.Show(exception.Message); PasswordBox.Clear(); } } else { MessageBox.Show("All fields must be filled"); PasswordBox.Clear(); } }
// Event-handler, der lytter efter om passwordet i HomeViewModel bliver tomt private void ViewModel_PropertyChanged(object sender, PropertyChangedEventArgs e) { if (((HomeViewModel)sender).SecurePassword.Length == 0) { PasswordBox.Clear(); } }
public void TraverseVisualTree(Visual myMainWindow) { int childrenCount = VisualTreeHelper.GetChildrenCount(myMainWindow); for (int i = 0; i < childrenCount; i++) { var visualChild = (Visual)VisualTreeHelper.GetChild(myMainWindow, i); if (visualChild is TextBox) { TextBox tb = (TextBox)visualChild; tb.Clear(); } if (visualChild is PasswordBox) { PasswordBox pb = (PasswordBox)visualChild; pb.Clear(); } if (visualChild is ComboBox) { ComboBox cb = (ComboBox)visualChild; cb.Text = string.Empty; } TraverseVisualTree(visualChild); } }
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); } }
private void SaveButton_Click(object sender, RoutedEventArgs e) { bool isPasswordDiff = OldPasswordBox.Password != PasswordBox.Password && OldPasswordBox.Password != RepeatPasswordBox.Password; bool isOldPassCorrect = _user.Password == OldPasswordBox.Password; bool isPasswordSame = PasswordBox.Password == RepeatPasswordBox.Password; if (isOldPassCorrect && isPasswordDiff && isPasswordSame) { using (var context = new ExpansesManagerContext()) { _user.Password = PasswordBox.Password; context.Users.AddOrUpdate(_user); context.SaveChanges(); } UsernameTextBox.Clear(); PasswordBox.Clear(); RepeatPasswordBox.Clear(); OldPasswordBox.Clear(); ErrorLabel.Content = "Successfully Changed Password !"; } else { ErrorLabel.Content = Checks.PasswordsDoNotMatch; } }
private void SignIn_Click(object sender, EventArgs e) { if (LoginBox.Text.Length == 0) { Message.Warning("Empty login!", Text); return; } if (PasswordBox.Text.Length == 0) { Message.Warning("Empty password!", Text); return; } bool success = DB.Login(LoginBox.Text, PasswordBox.Text); if (!success) { Message.Error(DB.Status, Text); PasswordBox.Clear(); PasswordBox.Focus(); } else { LoginBox.Clear(); PasswordBox.Clear(); MainForm form = new MainForm(); form.Show(this); Hide(); } }
private void SignUp_Click(object sender, EventArgs e) { if (LoginBox.Text.Length == 0) { Message.Warning("Empty login!", Text); return; } if (PasswordBox.Text.Length == 0) { Message.Warning("Empty password!", Text); return; } bool result = DB.CheckLogin(LoginBox.Text); if (!result) { Message.Error(DB.Status, Text); } else { result = DB.Register(LoginBox.Text, PasswordBox.Text); if (!result) { Message.Error(DB.Status, Text); } else { Message.Info("You have successfully registered!" + Environment.NewLine + "Log in using the registration data.", Text); } Journal.Append(String.Format("{0} registered", LoginBox.Text)); } LoginBox.Clear(); PasswordBox.Clear(); LoginBox.Focus(); }
private async void DoLogin(PasswordBox pb) { LoaderManager.Instance.ShowLoader(); TimerServerClient serv = null; try { serv = new TimerServerClient(StationManager.EndpointName); var result = await Task.Run(() => { if (!serv.UserExists(Username, pb.Password)) { return(null); } User user = serv.GetUser(Username, pb.Password); user.Groups = serv.GetUserGroups(user).ToList(); user.Records = serv.GetUserRecords(user).ToList(); return(user); }); if (result == null) { MessageBox.Show("Oooops. Couldn't find you."); LoaderManager.Instance.HideLoader(); return; } else { StationManager.CurrentUser = result; var record = await Task.Run(() => serv.GetUserRecords(result).Where(r => r.EndTime == null).FirstOrDefault()); if (record != null) { record.User = result; StationManager.CurRecord = record; } else { Record rec = new Record(); rec.User = result; rec.Id = Guid.NewGuid(); StationManager.CurRecord = rec; } LoaderManager.Instance.HideLoader(); pb.Clear(); NavigationManager.Instance.Navigate(ViewType.MainView); } } catch (Exception e) { MessageBox.Show("Ooops, problems with server \n" + e.Message); LoaderManager.Instance.HideLoader(); } finally { serv?.Close(); } }
//Clear Password Box private void PasswordBox_MouseEnter(object sender, MouseEventArgs e) { if (this.mouseEnterPassword == false) { PasswordBox.Clear(); this.mouseEnterPassword = true; } }