コード例 #1
0
        public ActionResult LogOut(LogInModel model)
        {
            var autheticationManager = HttpContext.GetOwinContext().Authentication;
            autheticationManager.SignOut();

            return RedirectToAction("Index", "Home");
        }
コード例 #2
0
        public ActionResult Login(string returnUrl)
        {
            var loginModel = new LogInModel()
            {
                ReturnUrl = returnUrl
            };

            return View(loginModel);
        }
コード例 #3
0
        public async Task<ActionResult> LogIn(LogInModel model)
        {
            if (!ModelState.IsValid)
            {
                return View();
            }

            var user = await UserManager.FindByNameOrEmailAsync(model.Login, model.Password);            

            if (user != null)
            {
                var roleResult = UserManager.AddToRole(user.Id, "Regular");
                await SignInAsync(user, model.RememberMe);

                return Redirect(GetRedirectUrl(model.ReturnUrl));
            }

            return View();
        }