public ActionResult VerifyCode(VerifyCodeViewModel model) { if (!ModelState.IsValid) { return(View(model)); } if (HttpContext.Session != null) { var token = HttpContext.Session["ConfirmToken"] as ConfirmToken; if (token != null) { var confirmOperation = _authorizeClient.ConfirmOperation(token, Encoding.UTF8.GetBytes(model.Code)); if (confirmOperation != null) { HttpContext.Session[ControllerExtentions.UserTokenParamName] = confirmOperation; FormsAuthentication.SetAuthCookie(token.Username, false); return(RedirectToLocal(model.ReturnUrl)); } } } ModelState.AddModelError("", "Неверный код."); return(View(model)); }