/// <summary> /// 获取当前登录账号 /// </summary> /// <returns></returns> protected string GetCurrentUserNo() { OperatorVo operatorVo = HttpContext.Session.Get <OperatorVo>(AuthorizeFilterAttribute.SESSION_LOGIN_USER); if (null == operatorVo) { return(""); } return(operatorVo.userNo); }
/// <summary> /// 授权校验 /// </summary> /// <param name="context"></param> public void OnAuthorization(AuthorizationFilterContext context) { if (((AuthorizeValue >> (int)AuthorizeType.CheckLogin) & 0x01) > 0) { OperatorVo key = SessionUtils.Get <OperatorVo>(LoginSessionKey); if (key == null) { context.Result = new JsonResult(new JsonResponses("未登录")); return; } } }
/// <summary> /// 获取当前用户的所有平台列表 /// </summary> /// <returns></returns> protected List <long> GetCurrentUserPlatfromNos() { List <long> platformList = new List <long>(); OperatorVo operatorVo = HttpContext.Session.Get <OperatorVo>(AuthorizeFilterAttribute.SESSION_LOGIN_USER); if (null == operatorVo) { return(platformList); } platformList = DataHandleManager.Instance().PsPlatformHandle.GetChildPlatformNoList(operatorVo.platformNo); return(platformList); }
/// <summary> /// 登录成功后 /// </summary> /// <param name="users"></param> private void LoginAfterSuccess(UcUsers users) { string userNo = users.UserNo; UcUsersSetting usersSetting = DataHandleManager.Instance().UcUsersSettingHandle.GetUcUsersSettingInfo(userNo); if (usersSetting == null) { return; } OperatorVo operatorVo = new OperatorVo() { userNo = userNo, platformNo = usersSetting.PlatformNo }; HttpContext.Session.Set(AuthorizeFilterAttribute.LoginSessionKey, operatorVo); }
/// <summary> /// 授权校验 /// </summary> /// <param name="context"></param> public void OnAuthorization(AuthorizationFilterContext context) { if (((AuthorizeValue >> (int)AuthorizeType.CheckLogin) & 0x01) > 0) {// 检查是否登录 OperatorVo operatorVo = CheckLogin(context); if (operatorVo == null) { context.Result = new JsonResult(new JsonResponses("未登录")); return; } } if (((AuthorizeValue >> (int)AuthorizeType.CheckPermission) & 0x01) > 0) {// 检查权限 JsonResponses responses = managementSDK.VaildUserManagement(this.BeTestedManagement); if (!responses.ValidateResponses()) { context.Result = new JsonResult(responses); return; } } }
/// <summary> /// 检查是否登录 /// </summary> /// <param name="context"></param> /// <returns></returns> private OperatorVo CheckLogin(AuthorizationFilterContext context) { OperatorVo operatorVo = SessionUtils.Get <OperatorVo>(SESSION_LOGIN_USER); if (operatorVo != null) { return(operatorVo); } string sessionId = SessionUtils.GetSessionId("session_token"); CookieCollection cookieCollection = new CookieCollection(); foreach (var item in context.HttpContext.Request.Cookies) { cookieCollection.Add(new Cookie(item.Key, item.Value)); } cookieCollection.Add(new Cookie("session_token", sessionId)); HttpWebRequestUtil.ProcessCookies(cookieCollection); operatorVo = loginSdk.GetCurrentOperator(); if (operatorVo != null) { SessionUtils.Set(SESSION_LOGIN_USER, operatorVo); } return(operatorVo); }
public ActionResult <JsonResponses> GetCurrentOperator() { OperatorVo operatorVo = HttpContext.Session.Get <OperatorVo>(AuthorizeFilterAttribute.LoginSessionKey); return(new JsonResponses(operatorVo)); }