コード例 #1
0
        public ActionResult SignIn(PPEManager.UI.Models.Authentication.UserDetails userDetails, string ReturnUrl)
        {
            if (!ModelState.IsValid)
                return View(userDetails);

            var authenticationResult = Authenticator.AuthenticateUser(userDetails.UserName,userDetails.Password);

            if (authenticationResult.IsAuthenticated)
            {
                _auth.SetAuthCookie(userDetails.UserName, false);

                if (!string.IsNullOrEmpty(ReturnUrl))
                    return Redirect(ReturnUrl);
                else
                    return RedirectToAction("Index", "Home");
            }
            else
            {
                ModelState.AddModelError(string.Empty, authenticationResult.ErrorMessage);
                return View();
            }
        }