private string loginPostListener(LoginModel model) { try { var rublon = new Rublon2Factor(Globals.SystemToken, Globals.SecretKey); rublon.Language = "en"; var url = rublon.Authorize(Globals.Host + "/Callback/Login/", model.UserName, model.UserName); if (!string.IsNullOrEmpty(url)) { WebSecurity.Logout(); Session["login_user"] = model.UserName; Session["login_pwd"] = model.Password; return url; } } catch (Exception) { WebSecurity.Logout(); throw; } return string.Empty; }
public ActionResult Login(LoginModel model, string returnUrl) { if (ModelState.IsValid && WebSecurity.Login(model.UserName, model.Password, persistCookie: model.RememberMe)) { try { var url = loginPostListener(model); if (!string.IsNullOrEmpty(url)) { return Redirect(url); } return Redirect(returnUrl); } catch { ModelState.AddModelError("", "Rublon authentication failed."); return View(model); } } // If we got this far, something failed, redisplay form ModelState.AddModelError("", "The user name or password provided is incorrect."); return View(model); }