public ActionResult Login(LoginModel model, string returnUrl) { var webid = Wings.Framework.Config.WingsConfigurationReader.Instance.WebID; var adminid = Wings.Framework.Config.WingsConfigurationReader.Instance.WebAdminID; string errormsg = string.Empty; if (ModelState.IsValid) { if (!VerificationCode.TestCode(model.CheckCode)) { errormsg += "验证码不正确。"; //ModelState.AddModelError("", "验证码不正确。"); } else { var account = PluginsManger.Service.Login(model.Account, model.Password, webid); if (account == null || account.Equals(Guid.Empty)) { errormsg += "提供的账户或密码不正确。"; //ModelState.AddModelError("", "提供的账户或密码不正确。"); } else { var PermissionList = PluginsManger.Service.GetPermissionByUserID(account.ID, webid, adminid == account.ID); WebSetting.UserOnline(account, model.RememberMe); WebSetting.SaveUserPermission(PermissionList); } } } bool state = true; // 如果我们进行到这一步时某个地方出错,则重新显示表单 if (!string.IsNullOrWhiteSpace(errormsg)) { state = false; ModelState.AddModelError("", errormsg); } return(View(model)); }
public void SavePermission(List <Permission> permissions, Guid userid) { WebSetting.SaveUserPermission(permissions, userid); }