public ObjectResultEx SystemLogin(RequestValidate LoginValidate) { try { ResponseAdmin SysAdmin = SystemService.SystemLogin(LoginValidate); string Code = string.Empty; if (!LoginValidate.IsApp) { Code = CacheFactory.Cache().GetCache <string>("ValidateCode").Trim(); if (SysAdmin != null && Code.ToUpper().Equals(LoginValidate.ValidateCode.Trim().ToUpper())) { CookieInfo cookie = new CookieInfo(); VerificationExtension.WriteToken(cookie, SysAdmin); return(ObjectResultEx.Instance(new { ResponseCookieInfo.RSAToKen, ResponseCookieInfo.RSAApiKey, ResponseCookieInfo.RSASysKey, SysAdmin }, 1, RetrunMessge.SUCCESS, HttpCode.Success)); } else if (!Code.ToUpper().Equals(LoginValidate.ValidateCode.Trim().ToUpper())) { return(ObjectResultEx.Instance(null, -1, "验证码错误", HttpCode.NoAuth)); } else { return(ObjectResultEx.Instance(null, -1, "登录失败或账户冻结", HttpCode.NoAuth)); } } else { if (SysAdmin != null) { CookieInfo cookie = new CookieInfo(); VerificationExtension.WriteToken(cookie, SysAdmin); return(ObjectResultEx.Instance(new { ResponseCookieInfo.RSAToKen, ResponseCookieInfo.RSAApiKey, ResponseCookieInfo.RSASysKey, SysAdmin }, 1, RetrunMessge.SUCCESS, HttpCode.Success)); } else if (!Code.ToUpper().Equals(LoginValidate.ValidateCode.Trim().ToUpper())) { return(ObjectResultEx.Instance(null, -1, "验证码错误", HttpCode.NoAuth)); } else { return(ObjectResultEx.Instance(null, -1, "登录失败或账户冻结", HttpCode.NoAuth)); } } } catch (Exception) { return(ObjectResultEx.Instance(null, -1, "请输入验证码", HttpCode.FAIL)); } }
/// <summary> /// 缓存中取登陆信息 /// </summary> /// <returns></returns> public ResponseAdmin UserInfo() { ResponseAdmin Data = Cache.GetCache <ResponseAdmin>(SystemInfoKey.PrivateKey); return(Data == null ? null : (Data.TableName.Equals(typeof(ResponseAdmin).Name) ? Data : null)); }