Ejemplo n.º 1
0
        public ActionResult SignIn(SignInVM viewModel, string returnUrl)
        {
            if (!ModelState.IsValid)
                return View("SignIn", viewModel);

            Mapper.CreateMap<SignInVM, UserSM>();
            var user = Mapper.Map<UserSM>(viewModel);
            bool passwordMatches = _authenticationService.PasswordMatches(user, viewModel.Password);
            if(passwordMatches)
            {
                FormsAuthentication.SetAuthCookie(viewModel.Username, viewModel.RememberMe);
                if (Url.IsLocalUrl(returnUrl) && returnUrl.Length > 1 && returnUrl.StartsWith("/")
                    && !returnUrl.StartsWith("//") && !returnUrl.StartsWith("/\\"))
                {
                    return Redirect(returnUrl);
                }
                return RedirectToAction("Index", "Umbrella");
            }
            ModelState.AddModelError("SignIn", "Invalid credentials");
            return View("SignIn", viewModel);
        }
Ejemplo n.º 2
0
 public ActionResult SignIn()
 {
     var viewModel = new SignInVM();
     return View(viewModel);
 }