Ejemplo n.º 1
0
 public ActionResult Login(string returnUrl)
 {
     var db = new SpindleDbContext();
     var vm = new LoginViewModel(){
         LastPost = db.Posts.OrderByDescending(p => p.CreatedDate).FirstOrDefault()
     };
     ViewBag.ReturnUrl = returnUrl;
     return View(vm);
 }
Ejemplo n.º 2
0
        public async Task<ActionResult> Login(LoginViewModel model, string returnUrl)
        {
            if (ModelState.IsValid)
            {
                // Validate the user password
                if (await Secrets.Validate(model.UserName, model.Password))
                {
                    string userId = await Logins.GetUserId(IdentityConfig.LocalLoginProvider, model.UserName);
                    await SignIn(userId, model.RememberMe);

                    return RedirectToLocal(returnUrl);
                }
            }

            // If we got this far, something failed, redisplay form
            ModelState.AddModelError(String.Empty, "The user name or password provided is incorrect.");

            return View(model);
        }