public ActionResult Login(LoginModel model, string returnUrl) { if (ModelState.IsValid) { return LoginAndRedirect(model, returnUrl); } return View(); }
private ActionResult LoginAndRedirect(LoginModel model, string returnUrl) { AuthorizationInfoDTO authorizationInfoDTO; string tokenString = Request.QueryString["token"]; if (string.IsNullOrEmpty(tokenString) == false) { authorizationInfoDTO = AASWrapper.GetAuthorizationDataFromToken(tokenString); } else authorizationInfoDTO = AASWrapper.Authenticate(model.AccountDO.UserName, model.AccountDO.Password); if (authorizationInfoDTO != null) { EmptySession(); Session.Add(Entegral.AuAz.Constants.SESSIONKEY_AUAZ_AUTHORIZATION_INFO, authorizationInfoDTO); HttpCookie formsAuthenticationTicketCookie = Entegral.AuAz.Utils.GetFormsAuthenticationCookie(authorizationInfoDTO); Response.Cookies.Add(formsAuthenticationTicketCookie); if (Url.IsLocalUrl(returnUrl) && returnUrl.Length > 1 && returnUrl.StartsWith("/") && !returnUrl.StartsWith("//") && !returnUrl.StartsWith("/\\")) { return Redirect(returnUrl); } else { return RedirectToAction("Index", "Home"); } } else { ModelState.AddModelError("LogonError", "Giriş başarısız. Lütfen tekrar deneyin..."); } return View(); }