Ejemplo n.º 1
0
        public ActionResult Login(string returnUrl)
        {
            if (this.User.Identity.IsAuthenticated)
            {
                return this.RedirectToReturnUrl(returnUrl);
            }

            var model = new AccountsLoginViewModel { ReturnUrl = returnUrl };
            return this.View(model);
        }
Ejemplo n.º 2
0
        public async Task<ActionResult> Login(AccountsLoginViewModel model)
        {
            if (!this.ModelState.IsValid)
            {
                return this.View(model);
            }

            var user = await this.UserManager.FindAsync(model.Username, model.Password);
            if (user != null)
            {
                this.SignInAsync(user, model.IsPersistent);

                return this.RedirectToReturnUrl(model.ReturnUrl);
            }

            this.ModelState.AddModelError("model", "Invalid username or password.");

            return this.View(model);
        }