public ActionResult Login(LoginModel input) { var user = RavenSession.GetUserByEmail(input.Email); if (ModelState.IsValid && (user == null || !user.ValidatePassword(input.Password))) { ModelState.AddModelError("UserNotExistOrPasswordNotMatch", "Email and / or password is incorrect."); } if (ModelState.IsValid) { FormsAuthentication.SetAuthCookie(input.Email, true); if (!string.IsNullOrWhiteSpace(input.ReturnUrl)) { return(Redirect(input.ReturnUrl)); } return(RedirectToRoute(new { controller = "Posts", action = "Index" })); } return(View(new LoginModel { Email = input.Email, ReturnUrl = input.ReturnUrl })); }
public ActionResult CurrentUser() { if (Request.IsAuthenticated == false) { return(View(new CurrentUserViewModel())); } var user = RavenSession.GetUserByEmail(HttpContext.User.Identity.Name); return(View(new CurrentUserViewModel { FullName = user.FullName })); // TODO: we don't really need a VM here }
public ActionResult Index(LogOnModel input) { var user = RavenSession.GetUserByEmail(input.Login); if (user == null || user.ValidatePassword(input.Password) == false) { ModelState.AddModelError("UserNotExistOrPasswordNotMatch", "Email and password do not match to any known user."); } else if (user.Enabled == false) { ModelState.AddModelError("NotEnabled", "The user is not enabled"); } if (ModelState.IsValid) { FormsAuthentication.SetAuthCookie(input.Login, true); return(RedirectFromLoginPage(input.ReturnUrl)); } return(View(new LogOnModel { Login = input.Login, ReturnUrl = input.ReturnUrl })); }
public virtual ActionResult ContactMe() { var user = RavenSession.GetUserByEmail(BlogConfig.OwnerEmail); return(View(new ContactMeViewModel(user))); }