예제 #1
0
        public OutputData Insert(IInputData input, object instance)
        {
            LogOnData data = instance.Convert <LogOnData>();

            using (UserResolver resolver = new UserResolver(this))
            {
                IUserInfo userInfo = resolver.CheckUserLogOn(data.LogOnName, data.Password, 0);
                if (userInfo == null)
                {
                }

                var           response = WebGlobalVariable.Response;
                CookieOptions options  = new CookieOptions
                {
                    Expires = new DateTimeOffset(DateTime.Now.AddDays(30))
                };
                response.Cookies.Append(COOKIE_NAME, data.LogOnName, options);
                options = new CookieOptions
                {
                    Expires = new DateTimeOffset(JWTUtil.CalcValidTime())
                };
                string token = JWTUtil.CreateEncodingInfo(userInfo);
                response.Cookies.Append(JWTUtil.COOKIE_NAME, token, options);
                //CookieUserInfo cookieInfo = new CookieUserInfo(data, userInfo);
                //cookie = new HttpCookie(RightConst.USER_INFO_COOKIE_NAME, cookieInfo.Encode())
                //{
                //    Expires = GetExpireDate()
                //};
                //response.Cookies.Set(cookie);

                WebSuccessResult result;
                string           retUrl = input.QueryString["RetURL"];
                if (!string.IsNullOrEmpty(retUrl))
                {
                    result = new WebSuccessResult(retUrl);
                }
                else
                {
                    WebAppSetting appSetting = WebAppSetting.WebCurrent;
                    if (string.IsNullOrEmpty(appSetting.MainPath))
                    {
                        result = new WebSuccessResult(appSetting.HomePath);
                    }
                    else
                    {
                        string url     = HttpUtility.UrlEncode(appSetting.HomePath);
                        string mainUrl = UriUtil.AppendQueryString(appSetting.MainPath, "StartUrl=" + url);
                        result = new WebSuccessResult(mainUrl);
                    }
                }

                return(OutputData.CreateToolkitObject(result));
            }
        }
예제 #2
0
        public OutputData Insert(IInputData input, object instance)
        {
            LogOnData data = instance.Convert <LogOnData>();

            using (UserResolver resolver = new UserResolver(this))
            {
                IUserInfo userInfo = resolver.CheckUserLogOn(data.LogOnName, data.Password, 0);
                if (userInfo == null)
                {
                }
                WebGlobalVariable.SessionGbl.AppRight.Initialize(userInfo);

                var        response = WebGlobalVariable.Response;
                HttpCookie cookie   = new HttpCookie(COOKIE_NAME, data.LogOnName)
                {
                    Expires = DateTime.Now.AddDays(30)
                };
                response.Cookies.Set(cookie);
                CookieUserInfo cookieInfo = new CookieUserInfo(data, userInfo);
                cookie = new HttpCookie(RightConst.USER_INFO_COOKIE_NAME, cookieInfo.Encode())
                {
                    Expires = GetExpireDate()
                };
                response.Cookies.Set(cookie);

                WebSuccessResult result;
                var    request = WebGlobalVariable.Request;
                string retUrl  = request.QueryString["RetURL"];
                if (!string.IsNullOrEmpty(retUrl))
                {
                    result = new WebSuccessResult(retUrl);
                }
                else
                {
                    WebAppSetting appSetting = WebAppSetting.WebCurrent;
                    if (string.IsNullOrEmpty(appSetting.MainPath))
                    {
                        result = new WebSuccessResult(appSetting.HomePath);
                    }
                    else
                    {
                        string url     = HttpUtility.UrlEncode(appSetting.HomePath);
                        string mainUrl = UriUtil.AppendQueryString(appSetting.MainPath, "StartUrl=" + url);
                        result = new WebSuccessResult(mainUrl);
                    }
                }

                return(OutputData.CreateToolkitObject(result));
            }
        }