public void CheckLogin() { User _testNotExistingUser = new User { UserId = 1, UserEmail = "*****@*****.**", Password = "******", FirstName = "Davey", LastName = "Cornelissen", BirthDay = DateTime.Now, PhoneNumber = "0628433115", PpPath = "/Test/Profile.PNG" }; _accountLogic.CheckLogin(_testNotExistingUser.UserEmail, _testNotExistingUser.Password); }
public IActionResult Login(Login login) { if (!ModelState.IsValid) { return(View("Login", login)); } login = AccountLogic.CheckLogin(login); Account account = AccountLogic.GetAccount(login.ID); if (account.MiddleName == null) { HttpContext.Session.SetString("FullName", account.FirstName + " " + account.LastName); } else { HttpContext.Session.SetString("FullName", account.FirstName + " " + account.MiddleName + " " + account.LastName); } HttpContext.Session.SetString("AccountID", account.ID.ToString()); if (account.Admin) { return(RedirectToAction("Index", "Manage")); } else { return(RedirectToAction("Index", "Home")); } }
public void CheckLoginTest() { //arrange IAccountContext context = new TestDateContext(); AccountLogic logic = new AccountLogic(); string email = "*****@*****.**"; string password = "******"; //act bool checklogin = logic.CheckLogin(context, email, password); //assert Assert.IsTrue(checklogin); }
public IActionResult Login(LoginViewModel model) { if (_accountLogic.CheckLogin(model.Email, model.Password)) { HttpContext.Session.SetString(SessionKeyName, model.Email); Account account = _accountLogic.GetUser(model.Email); if (account.IsAdmin) { HttpContext.Session.SetString(SessionKeyIsAdmin, "1"); return(RedirectToAction("Index", "Home")); } return(RedirectToAction("Index", "Home")); } ModelState.AddModelError("", "Username or Password was incorrect"); return(View(model)); }
public async Task <IActionResult> Login(LoginViewModel model) { if (!ModelState.IsValid) { return(View(model)); } try { //check if the user input is valid _accountLogic.CheckLogin(model.Email, model.Password); //Get the cookie info User cookieInfo = _accountLogic.GetCookieInfo(model.Email); CookieCreate cookieCreate = new CookieCreate(); cookieCreate.addClaims("Id", cookieInfo.UserId.ToString()); cookieCreate.addClaims("UserName", cookieInfo.FirstName); cookieCreate.addClaims("UserPicture", cookieInfo.PpPath); var claimsPrincipal = cookieCreate.CreateCookieAuth("FishCookies"); //to login the user await HttpContext.SignInAsync( "FishCookies", claimsPrincipal, new AuthenticationProperties { IsPersistent = model.Remember }); return(RedirectToAction("TimeLine", "Timeline")); } catch (ExceptionHandler exception) { ViewData[exception.Index] = exception.Message; return(View()); } }