protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                string cAccount = Context.Request["childText"];
                string pAccount = Context.Request["parentText"];
                string psw = Context.Request["pwdText"];
                //登录条件:子账号、企业账号、密码、状态正常(status=0)
                string userWhere = " ChildAccount ='" + cAccount + "' AND ParentAccount='" + pAccount + "' AND Password='******' AND Status=" + 0;

                IList<UsersEntity> userList = DataProvider.GetInstance().GetUsersList(userWhere);
                if (userList.Count <= 0)
                {
                    //登录失败
                    Alert("账号或密码不正确,请确认!", "/index.html");
                    return;
                }
                #region 权限控制
                Authorization.Authorization currAuthor = new Authorization.Authorization();
                int timeout = currAuthor.Validate(userList[0]);
                Session["cacheKey"] = currAuthor;
                Session.Timeout = timeout;
                #endregion

                #region 记录日志
                string logContent = "[" + userList[0].ChildAccount + "@" + userList[0].ParentAccount + "]成功登录系统!";
                WriteLog("Longin.ashx", "ProcessRequest", logContent, userList[0].ID);

                #endregion

                #region 成功返回
                Context.Response.Redirect("/Main.html", true);

                return;

                #endregion
            }
            catch(Exception ex)
            {
                //系统原因返回失败
                Alert("系统发现有异常,请重新尝试!", "/index.html");
            }

        }
Exemplo n.º 2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="SkroutzRequest" /> class
        /// </summary>
        /// <param name="credentials">The Authorization Credentials</param>
        /// <param name="apiVersion">The API Version</param>
        /// <exception cref="ArgumentNullException">Thrown when <paramref name="credentials.ClientId" /> or <paramref name="credentials.ClientSecret" /> are null or empty.</exception>
        public SkroutzRequest(Credentials credentials, string apiVersion = null)
        {
            if (string.IsNullOrEmpty(credentials.ClientId))
            {
                throw new ArgumentNullException(nameof(credentials.ClientId));
            }

            if (string.IsNullOrEmpty(credentials.ClientSecret))
            {
                throw new ArgumentNullException(nameof(credentials.ClientSecret));
            }

            if (!string.IsNullOrEmpty(apiVersion))
            {
                this.ApiVersion = apiVersion;
            }

            Authorization.Authorization authorization = new Authorization.Authorization(this, credentials);
            this.AuthResponse = authorization.AuthResponse;

            this.SBuilder = new StringBuilder();
        }
Exemplo n.º 3
0
        /// <summary>
        /// 权限过期得重新登录
        /// </summary>
        /// <param name="e"></param>
        protected override void OnInit(EventArgs e)
        {
            base.OnInit(e);
            if (System.Web.HttpContext.Current != null && !this.DesignMode)
            {

                CurrentAuthor = Session["cacheKey"] as Authorization.Authorization;
                if (CurrentAuthor == null
                    || CurrentAuthor.GetAuthorizeMenus() == null
                    || CurrentAuthor.GetAuthorizeMenus().Count <= 0
                    || CurrentAuthor.GetAuthorizeUsers() == null)
                {
                    string ParentURL = indexUrl;
                    //string ParentURL = Request.ApplicationPath + indexUrl;
                    System.Web.HttpContext.Current.Response.Write("<script language='javascript'>if(parent.AlertAndgoBack!=null ) { parent.AlertAndgoBack('" + ParentURL + "') ;} else {alert('您当前没有权限浏览本页面,请重新登录!'); window.location.href='" + ParentURL + "';};</script>");
                    Response.End();
                }

                CurrentUser = CurrentAuthor.GetAuthorizeUsers();
            }

        }
Exemplo n.º 4
0
 protected void Logout()
 {
     CurrentAuthor.Logout();
     CurrentAuthor = null;
     Session.RemoveAll();
     Session.Abandon();
     string ParentURL = indexUrl;
     //string ParentURL = Request.ApplicationPath + indexUrl;
     Response.Redirect(ParentURL);
 }