public static void Login(VerifiedData data)
        {
            try
            {
                var login = _repo.StaffLoginWithFingerPrint(data.Id);
                if (login)
                {
                    _digitalPersona.StopCapture();
                    _digitalPersona?.Dispose();

                    var t = new Thread(new ThreadStart(DoNothing));
                    t.Start();
                    Thread.Sleep(2500);
                    t.Abort();
                    
                    var dashboard = new FrmContainer();
                    dashboard.Show();

                    foreach (var form in Application.OpenForms.OfType<FrmFingerprintLogin>().ToList())
                    {
                        form.Close();
                    }
                }
                else
                {
                    Base.ShowInfo("", "Login failed. Try again");
                }
            }
            catch (Exception e)
            {
                Base.ShowError("Error", e.Message);
            }
        }
Exemplo n.º 2
0
        private void btnLogin_Click(object sender, EventArgs e)
        {
            try
            {
                var model = new Login
                {
                    Email    = txtUsername.Text.Trim(),
                    Password = PasswordHash.sha256(txtPassword.Text)
                };

                if (model.Email.Length == 0 || model.Password.Length == 0)
                {
                    Base.ShowError("Required fields missing", "Email and Password cannot be empty");
                    return;
                }

                if (!Validations.IsValidEmail(model.Email))
                {
                    Base.ShowError("Invalid Email", "Email is invalid");
                    return;
                }

                if (_authRepo.StaffLogin(model))
                {
                    if (!LoggedInUser.PasswordChanged) // first time login
                    {
                        Base.ShowInfo("First time Login", "This is your first login with the default password. Kindly change your password");
                        var pwdForm = new FrmChangePassword(LoggedInUser.Email);
                        pwdForm.ShowDialog();
                        pwdForm.BringToFront();
                    }

                    using (var dashboard = new FrmContainer())
                    {
                        this.Hide();
                        this.ShowInTaskbar = false;
                        dashboard.ShowDialog();
                        dashboard.BringToFront();
                    }
                }
                else
                {
                    Base.ShowError("Invalid Login", "Username and Password is incorrect");
                    return;
                }
            }
            catch (Exception exception)
            {
                Console.WriteLine(exception);
                throw;
            }
        }