public ActionResult CreateUser(CreateUserModel model) { if (ModelState.IsValid) { // Email 或者 手机 string token = RdbmsWebSecurity.CreateUserAndAccount(model.UserName, model.Password, model.Email); if (token.HasValue()) { if (RdbmsWebSecurity.Login(model.UserName, model.Password, true)) { //去到个人信息页面 return(RedirectToAction("UserDetails", "Home", new { token = token, userName = model.UserName })); } } } return(View(model)); }
public ActionResult Login(LoginModel model, string returnUrl) { if (ModelState.IsValid) { string decodedReturnUrl = this.Server.UrlDecode(returnUrl); bool isLocalUrl = !returnUrl.HasValue() || Url.IsLocalUrl(decodedReturnUrl); string passportToken = RdbmsWebSecurity.LoginAndCreateSSOToken(model.UserNameOrEmailOrCellPhoneNo, model.Password); if (!passportToken.HasValue()) { return(View(model)); } if (isLocalUrl) { if (Url.IsLocalUrl(returnUrl) && returnUrl.Length > 1 && returnUrl.StartsWith("/") && !returnUrl.StartsWith("//") && !returnUrl.StartsWith("/\\")) { return(Redirect(decodedReturnUrl)); } else { return(RedirectToAction("UserDetails", "Home", new { token = passportToken, userName = model.UserNameOrEmailOrCellPhoneNo })); } } else { string newRedirectedUrl = string.Format("{0}{1}token={2}&username={3}&remark={4}", decodedReturnUrl, "?", passportToken, model.UserNameOrEmailOrCellPhoneNo, "Success"); return(Redirect(newRedirectedUrl)); } } return(View(model)); }
public ActionResult Login(LoginModel loginModel, string returnUrl) { if (ModelState.IsValid) { if (RdbmsWebSecurity.Login(loginModel.UserName, loginModel.Password, true)) { if (!string.IsNullOrEmpty(returnUrl) && Url.IsLocalUrl(returnUrl) && returnUrl.Length > 1 && returnUrl.StartsWith("/") && !returnUrl.StartsWith("//") && !returnUrl.StartsWith("/\\")) { return(Redirect(returnUrl)); } else { return(RedirectToAction("Index", "Home")); } } } return(View(loginModel)); }