protected bool doLogin(String username, String password)
        {
            bool result = false;

            UserPool userPool = (UserPool)Application["UserPool"];

            if (userPool.RegisterUser(username, password))
            {
                ltMessage.Text = "";

                FormsAuthentication.SignOut();
                FormsAuthentication.SetAuthCookie(username, false);


                Int32 userId     = userPool.GetUserId(username);
                Int32 userRoleId = userPool.GetUserRoleId(username);


                //----------------------------------------
                UcUserArgs args = new UcUserArgs();
                args.UserName   = username;
                args.Password   = password;
                args.UserId     = userId;
                args.UserRoleId = userRoleId;
                login(args);
                //----------------------------------------

                if (!args.Cancel)
                {
                    result = true;
                }
                else
                {
                    result = false;
                    doLogout(args.Message);
                }
            }
            else
            {
            }

            return(result);
        }
Ejemplo n.º 2
0
        private bool DoLogin(String username, String password)
        {
            UserPool userPool = (UserPool)Application["UserPool"];

            if (userPool.RegisterUser(username, password))
            {
                FormsAuthentication.SignOut();
                FormsAuthentication.SetAuthCookie(username, false);

                Int32 userId     = userPool.GetUserId(username);
                Int32 userRoleId = userPool.GetUserRoleId(username);

                UcUserArgs args = new UcUserArgs();
                args.UserName   = username;
                args.Password   = password;
                args.UserId     = userId;
                args.UserRoleId = userRoleId;
                login(args);

                return(true);
            }

            return(false);
        }
Ejemplo n.º 3
0
        private void AuthorizeRequest(object r_objSender, EventArgs r_objEventArgs)
        {
            HttpApplication objApp     = (HttpApplication)r_objSender;
            HttpContext     objContext = this.getContext(objApp);

            string url = objContext.Request.Url.ToString();

            if (url.Contains(".aspx"))
            {
                Int32 userRoleId   = 0;
                bool  isAuthorized = false;

                //HttpApplication objApp = (HttpApplication)r_objSender;
                //HttpContext objContext = this.getContext(objApp); ;

                //string url = objContext.Request.Url.ToString();



                if (url.Contains(@"/dir"))
                {
                    int i = url.IndexOf(@"/dir", 0);
                    int j = url.IndexOf(@"/", i + 1);
                    url = url.Substring(0, j + 1);
                }


                if (_username == "")
                {
                    if (
                        (url.Contains(@"/dirAdmin/")) ||
                        (url.Contains(@"/dirReport/")) ||
                        (url.Contains(@"/dirAgent/")) ||
                        (url.Contains(@"/dirUser/")) ||
                        (url.Contains(@"/dirKiosk/"))
                        )
                    {
                        isAuthorized = false;
                    }
                    else
                    {
                        isAuthorized = true;
                    }
                }
                else
                {
                    userRoleId = _userPool.GetUserRoleId(_username);


                    if ((url.Contains(@"/dirAdmin/")) || (url.Contains(@"/dirReport/")) || (url.Contains(@"/dirAgent/")) || (url.Contains(@"/dirUser/")))
                    {
                        switch (userRoleId)
                        {
                        case 1:     // Admin
                            if ((url.Contains(@"/dirCommon/")) || (url.Contains(@"/dirUser/")) || (url.Contains(@"/dirAdmin/")) || (url.Contains(@"/dirReport/")))
                            {
                                isAuthorized = true;
                            }
                            break;

                        case 2:     // Agent
                            if ((url.Contains(@"/dirCommon/")) || (url.Contains(@"/dirUser/")) || (url.Contains(@"/dirAgent/")))
                            {
                                isAuthorized = true;
                            }
                            break;

                        case 3:     // Manager
                            if ((url.Contains(@"/dirCommon/")) || (url.Contains(@"/dirUser/")))
                            {
                                isAuthorized = true;
                            }
                            break;

                        case 4:     // User
                            if ((url.Contains(@"/dirCommon/")) || (url.Contains(@"/dirUser/")))
                            {
                                isAuthorized = true;
                            }
                            break;

                        case 5:     // Supervisor
                            if ((url.Contains(@"/dirCommon/")) || (url.Contains(@"/dirUser/")) || (url.Contains(@"/dirAdmin/")) || (url.Contains(@"/dirReport/")))
                            {
                                isAuthorized = true;
                            }
                            break;

                        default:
                            if (url.Contains(@"/dirCommon/"))
                            {
                                isAuthorized = true;
                            }
                            break;
                        }
                    }
                    else
                    {
                        isAuthorized = true;
                    }
                }



                //-------------------------------------------------------------------
                objContext.Items.Add("UserRoleId", userRoleId);
                objContext.Items.Add("IsAuthorized", isAuthorized);
            }
        }