public IMySession SetCurrentSession(TenantUser user) { var mySession = new MySession { TenantName = user.Name, UserId = user.Id }; mySession.Id = Guid.NewGuid().ToString("N"); RedisHelper.SetEntity(mySession); return mySession; }
public override void OnActionExecuting(ActionExecutingContext filterContext) { return; var context = filterContext.HttpContext; var mySession =IocManager.Resolve<IMySession>() ; if (mySession.UserName.IsNotNull()) return; var code = context.Request["code"]; var state = context.Request["state"]; if (code.IsNotNull() && state.IsNotNull()) { var userInfo = HttpHelper.Post<QYHResult>(strGetUserCode, new { code = code, state = state }); mySession = new MySession { UserName=userInfo.UserCode }; } var ret = HttpHelper.Post<QYHResult>(strGetRedirectUrl, new { soureUrl = context.Request.Url.AbsoluteUri }); context.Response.Redirect(ret.RedirectUrl); //if ( user.UserId.IsEmpty()) // filterContext.Result = new RedirectToRouteResult(new RouteValueDictionary(new { controller = "Account", action = "Login" })); //else //{ // var userid = context.Request.Headers["UserId"]; // if (!userid.Equals(user.UserId)) // { // throw new ValidationException("用户会话已改变,无法进行操作,请关闭此页面"); // } //} }