コード例 #1
0
        public ActionResult Login(string returnUrl)
        {
            var model = new LoginModel
            {
                ReturnUrl = returnUrl
            };

            return View(model);
        }
コード例 #2
0
        public ActionResult Login(LoginModel model)
        {
            if (!ModelState.IsValid)
            {
                return View(model);
            }
            var user = _applicationService.GetTeacherByLogin(model.Login);
            if (user == null)
            {
                AddWrongEmailPasswordError();
                return View(model);
            }

            if (model.Password == user.Password)
            {
                var identity = _authenticationService.CreateTeacherIdentity(user);
                _authenticationService.SignIn(identity, Request);

                return RedirectToAction("Index", "Home");
            }
            AddWrongEmailPasswordError();
            return View(model);
        }