public static User ConvertToDB(LogInUserViewModel user) { var currentUser = new User { Id = user.Id, Email = user.Email, Passwrd = user.Passwrd }; return currentUser; }
public ActionResult LogIn(LogInUserViewModel currentUser) { if (ModelState.IsValid) { var enteredUser = userService.IsEmailAndPassCorrect(currentUser); if (enteredUser != null) { HttpContext.Session["CurrentUser"] = enteredUser; Logger.Log.Debug("user ID:" + enteredUser.Id + " " + enteredUser.Email + " logged in"); return RedirectToAction("Newsfeed", "Tweet"); } else { ViewBag.errorMessage = "Email or Password is incorrect!"; return View(); } } return View(); }
public UserViewModel IsEmailAndPassCorrect(LogInUserViewModel model) { try { var curUser = userContext.GetList().FirstOrDefault(x => x.Email == model.Email); if (curUser != null) { if (curUser.Passwrd == model.Passwrd) return UserConverter.ConvertToViewModel(curUser); } } catch(Exception e) { Logger.Log.Error(e); } return null; }