Ejemplo n.º 1
0
        public IActionResult OnGet()
        {
            string username = HttpContext.Session.GetString("Username");

            System.Diagnostics.Debug.WriteLine($"UpdateStaff username: {username}");
            if (username == null || username == string.Empty)
            {
                return(new RedirectToPageResult("Index"));
            }

            ResolutionsSystem rs = new ResolutionsSystem();

            ToUpdateStaff = rs.GetLogin(HttpContext.Session.GetString("Username"));
            NewUsername   = ToUpdateStaff.Username;
            NewPassword   = ToUpdateStaff.Password;

            return(Page());
        }
Ejemplo n.º 2
0
        public JsonResult OnPostCheckUsername()
        {
            System.Diagnostics.Debug.WriteLine("OnPostCheckUsername()");

            ResolutionsSystem rs = new ResolutionsSystem();

            Classes.Login login = rs.GetLogin(Username);

            bool valid = false;

            if (login.Username == null)
            {
                valid = false;
            }
            else
            {
                valid = true;
            }

            return(new JsonResult(valid));
        }
Ejemplo n.º 3
0
        public IActionResult OnPost()
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }

            System.Diagnostics.Debug.WriteLine("OnPost()");
            bool authenticated = false;

            ResolutionsSystem rs = new ResolutionsSystem();

            Classes.Login login = rs.GetLogin(Username);
            System.Diagnostics.Debug.WriteLine($"Hash pass: {login.Password}");


            bool passwordVerified = Util.Verify(Password, login.Password);

            if (passwordVerified)
            {
                authenticated = true;
            }


            if (authenticated)
            {
                System.Diagnostics.Debug.WriteLine("User authenticated successfully");
                HttpContext.Session.Set("Username", Util.StringToByteArray(Username));
                HttpContext.Session.Set("StaffType", Util.StringToByteArray(login.StaffType));

                return(new RedirectToPageResult("Index"));
            }
            else
            {
                System.Diagnostics.Debug.WriteLine("Login failed");
                return(Page());
            }
        }