コード例 #1
0
        public async Task <IActionResult> Login(LoginViewModel login)
        {
            if (ModelState.IsValid)
            {
                Account acc =
                    await AccountDB.DoesUserMatch(login, _context);

                if (acc != null)
                {
                    SessionHelper.CreateUserSession
                        (acc.AccountID, acc.Username, _accessor);

                    return(RedirectToAction("Index", "Home"));
                }

                ModelState.AddModelError(string.Empty, "Invalid Credentials");
            }
            return(View());
        }