private void InitializeTabele() { TableName = typeof(T).Name; var entity = Table; if (entity != null) { TableId = entity.TableID; TableName = entity.TableName; PrimaryKey = entity.PrimaryKey; } else { var m = SaveTable(TableName); TableId = m.TableID; TableName = m.TableName; PrimaryKey = m.PrimaryKey; } if (string.IsNullOrEmpty(Account)) { string SessionName = BaseSystemConfig.SessionName; string sessionJson = WebHelper.GetCookie(SessionName); AccountModel loginStaffModel = DESEncryptHelper.DecryptDES(sessionJson).ToObject <AccountModel>(); if (loginStaffModel != null) { Account = loginStaffModel.StaffID; NickName = loginStaffModel.StaffName; } } }
public string GetVerifyCode(string cdoe) { string decodeCode = HttpUtility.UrlDecode(cdoe); string verifyCode = WebHelper.GetCookie("VerifyCode"); return(DESEncryptHelper.DecryptDES(verifyCode)); }
public void InitLoginData() { string sessionJson = WebHelper.GetCookie(SessionName); AccountModel loginStaffModel = DESEncryptHelper.DecryptDES(sessionJson).ToObject <AccountModel>(); if (loginStaffModel != null) { CompanyID = loginStaffModel.CompanyID; StaffID = loginStaffModel.StaffID; StaffName = loginStaffModel.StaffName; } }
public string GetVerifyCode(string cdoe) { try { string decodeCode = HttpUtility.UrlDecode(cdoe); string verifyCode = WebHelper.GetCookie("VerifyCode"); return(DESEncryptHelper.DecryptDES(verifyCode)); } catch (Exception ex) { throw new Exception(ex.Message); } }
public IActionResult Login() { string companyId = GetQueryString("CompanyID"); if (string.IsNullOrWhiteSpace(companyId)) { companyId = "sys"; } string sessionJson = WebHelper.GetCookie(SessionName); if (!string.IsNullOrEmpty(sessionJson)) { AccountModel loginStaffModel = DESEncryptHelper.DecryptDES(sessionJson).ToObject <AccountModel>(); if (loginStaffModel.Online) { return(RedirectToAction("index", "admin")); } } return(View(SiteConfig)); }
/// <summary> /// 验证权限(action执行前会先执行这里) /// </summary> /// <param name="filterContext"></param> public override void OnActionExecuting(ActionExecutingContext filterContext) { if (validate) { var SiteConfig = ConfigurationHelper.GetAppSettings <SiteConfig>("SiteConfig"); string loginUrl = SiteConfig.LoginUrl; var loginJosn = WebHelper.GetCookie(BaseSystemConfig.SessionName); var model = DESEncryptHelper.DecryptDES(loginJosn).ToObject <AccountModel>(); if (model == null) //如果不存在身份信息 { filterContext.Result = new RedirectResult(loginUrl); } else { string[] Role = model.Roles.Split(','); //获取所有角色 if (!Role.Contains(Roles)) //验证权限 { filterContext.Result = new RedirectResult(loginUrl); } } } }
public JsonResult Login(string companyId) { try { string username = GetFormValue("username"); string password = GetFormValue("password"); string verifyCode = GetFormValue("verifycode"); bool online = GetFormValue("online").ToBool(); string cookieVerifyCode = WebHelper.GetCookie("VerifyCode"); string decryptCookieVerifyCode = DESEncryptHelper.DecryptDES(cookieVerifyCode); string[] arrUserName = username.Split('@'); if (arrUserName.Length == 2) { companyId = arrUserName[0].ToString(); username = arrUserName[1].ToString(); } else { companyId = Utility.IIF(companyId, "sys"); } if (string.IsNullOrEmpty(username)) { return(Error("用户名不能为空!")); } if (string.IsNullOrEmpty(password)) { return(Error("密码不能为空!")); } if (string.IsNullOrEmpty(verifyCode)) { return(Error("验证码不能为空!")); } if (decryptCookieVerifyCode.ToUpper() != verifyCode.ToUpper()) { return(Error("验证码不正确!")); } var LoginResult = StaffService.VerifyStaffLoginPro(SystemID, companyId, username, AlgorithmHelper.MD5(password)); if (LoginResult) { var entityStaff = StaffService.GetVStaffPro(SystemID, companyId, username); string staffId = entityStaff.StaffID; string staffName = entityStaff.StaffName; string CompanyId = entityStaff.CompanyID; SaveLoginRecord(companyId, username, staffName, LoginResult, 1); AccountModel entity = new AccountModel() { SessionID = "", CompanyID = CompanyId, StaffID = username, StaffName = staffName, Online = online, Roles = "Admins" }; string userJson = DESEncryptHelper.EncryptDES(entity.ToJson()); WebHelper.WriteCookie(SessionName, userJson); return(Success("成功")); } else { SaveLoginRecord(companyId, username, "-", LoginResult, 2); return(Error("login fail")); } } catch (Exception ex) { return(Error(ex.Message)); } }