예제 #1
0
        //
        // GET: /Account/Login

        public ActionResult Index([FromBody] string Username, string Password)
        {
            bool success = LoginManager.CheckPassword(db, Username, Password);

            if (!success)
            {
                return(Failure("Bad username/password"));
            }
            return(Success("Logged in succesfully"));
        }
예제 #2
0
        public string Authenticate(string username, string password)
        {
            bool checkPassword = _loginManager.CheckPassword(username, password);

            if (!checkPassword)
            {
                return(string.Empty);
            }
            byte[] time = BitConverter.GetBytes(DateTime.UtcNow.ToBinary());
            byte[] key  = Guid.NewGuid().ToByteArray();
            return(Convert.ToBase64String(time.Concat(key).ToArray()));
        }
예제 #3
0
        private void loginButton_Click(object sender, EventArgs e)
        {
            // FUNCTION: check for the matric password is correct
            // PRE-CONDITIONS:
            // POST-CONDITIONS:

            if (passwordTextbox.Text == "" || matricTextbox.Text == "")
            {
                MessageBox.Show("Please enter your matriculation number and password.", "Entry Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
            }

            if (matricTextbox.Text == "Admin")
            {
                if (loginAdmin.CheckAdmin(passwordTextbox.Text))
                {
                    AdminPage adminPage = new AdminPage(server);
                    this.Hide();
                    adminPage.ShowDialog();
                    SerSave(server);
                    this.passwordTextbox.Clear();
                    this.matricTextbox.Clear();
                    this.Show();
                }
                else
                {
                    MessageBox.Show("Pasword in invalid, please try again!", "Entry Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                }
                matricTextbox.Focus();
                return;
            }

            if (loginAdmin.CheckPassword(matricTextbox.Text, passwordTextbox.Text))
            {
                DashBoardPage dashBoardPage = new DashBoardPage(matricTextbox.Text, server);
                this.Hide();
                dashBoardPage.ShowDialog();
                SerSave(server);
                this.passwordTextbox.Clear();
                this.matricTextbox.Clear();
                this.Show();
            }
            else
            {
                MessageBox.Show("Invalid matriculation number or password, please try again!", "Entry Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
            matricTextbox.Focus();
            return;
        }