Пример #1
0
 private void InitializeComponent()
 {
     if (!this.Page.IsPostBack)
     {
         if (!this.Context.User.Identity.IsAuthenticated)
         {
             string valueByCache = ConfigSystem.GetValueByCache("DefaultLoginAdmin");
             FormsAuthentication.SignOut();
             base.Session.Clear();
             base.Session.Abandon();
             base.Response.Clear();
             base.Response.Write(@"<script defer>window.alert('You do not have permission to access this page or session expired!\n Please login again or contact your administrator!');parent.location='" + valueByCache + "';</script>");
             base.Response.End();
         }
         else if (base.Session[Globals.SESSIONKEY_ADMIN] != null)
         {
             AccountsPrincipal principal = new AccountsPrincipal(((User) base.Session[Globals.SESSIONKEY_ADMIN]).UserName);
             if ((this.PermissionID != -1) && !principal.HasPermissionID(this.PermissionID))
             {
                 base.Response.Clear();
                 base.Response.Write(@"<script defer>window.alert('You do not have permission to access this page!\n Please login again or contact your administrator');history.back();</script>");
                 base.Response.End();
             }
         }
     }
 }
Пример #2
0
 protected virtual bool InitializeComponent(ActionExecutingContext filterContext)
 {
     if (base.HttpContext.User.Identity.IsAuthenticated)
     {
         try
         {
             this.userPrincipal = new AccountsPrincipal(base.HttpContext.User.Identity.Name);
         }
         catch (IdentityNotMappedException)
         {
             FormsAuthentication.SignOut();
             base.Session.Remove(Globals.SESSIONKEY_USER);
             base.Session.Clear();
             base.Session.Abandon();
             return false;
         }
         if (base.Session[Globals.SESSIONKEY_USER] == null)
         {
             this.currentUser = new User(this.userPrincipal);
             base.Session[Globals.SESSIONKEY_USER] = this.currentUser;
             base.Session["Style"] = this.currentUser.Style;
         }
         else
         {
             this.currentUser = (User) base.Session[Globals.SESSIONKEY_USER];
             base.Session["Style"] = this.currentUser.Style;
             ((dynamic) base.ViewBag).UserType = this.currentUser.UserType;
         }
         ((dynamic) base.ViewBag).CurrentUid = this.currentUser.UserID;
     }
     return true;
 }
Пример #3
0
        private void InitializeComponent()
        {
            if (!Page.IsPostBack)
            {
                if (Context.User.Identity.IsAuthenticated)
                {
                    AccountsPrincipal user = new AccountsPrincipal(Context.User.Identity.Name);
                    if (Session["UserInfo"] == null)
                    {
                        Maticsoft.Accounts.Bus.User currentUser = new Maticsoft.Accounts.Bus.User(user);
                        Session["UserInfo"] = currentUser;
                        Session["Style"] = currentUser.Style;
                        Response.Write("<script defer>location.reload();</script>");
                    }
                    if ((PermissionID != -1) && (!user.HasPermissionID(PermissionID)))
                    {
                        Response.Clear();
                        Response.Write("<script defer>window.alert('You do not have permission to access this page!\\n Please login again or contact your administrator');history.back();</script>");
                        Response.End();
                    }
                }
                else
                {
                    string defaullogin = Maticsoft.Common.ConfigHelper.GetConfigString("defaulloginadmin");
                    FormsAuthentication.SignOut();
                    Session.Clear();
                    Session.Abandon();
                    Response.Clear();
                    Response.Write("<script defer>window.alert('You do not have permission to access this page or session expired!\\n Please login again or contact your administrator!');parent.location='" + defaullogin + "';</script>");
                    Response.End();
                }

            }
        }
Пример #4
0
        //private void BindRoles(AccountsPrincipal user)
        //{
        //    if (user.Permissions.Count > 0)
        //    {
        //        RoleList.Visible = true;
        //        ArrayList Permissions = user.Permissions;
        //        RoleList.Text = "权限列表:<ul>";
        //        for (int i = 0; i < Permissions.Count; i++)
        //        {
        //            RoleList.Text += "<li>" + Permissions[i] + "</li>";
        //        }
        //        RoleList.Text += "</ul>";
        //    }
        //}
        protected void btnSave_Click(object sender, System.EventArgs e)
        {
            if (Page.IsValid)
            {
                string username = this.lblName.Text.Trim();
                AccountsPrincipal user = new AccountsPrincipal(username);
                User currentUser = new Maticsoft.Accounts.Bus.User(user);
                currentUser.UserName = username;
                currentUser.TrueName = txtTrueName.Text.Trim();
                //if (RadioButton1.Checked)
                //    currentUser.Sex = "1";
                //else
                //    currentUser.Sex = "0";
                //currentUser.Phone = this.txtPhone.Text.Trim();
                currentUser.Email = txtEmail.Text.Trim();
                //currentUser.UserType = dropUserType.SelectedValue;
                //int style = int.Parse(this.dropStyle.SelectedValue);
                //currentUser.Style = style;
                if (!currentUser.Update())
                {
                    this.lblMsg.ForeColor = Color.Red;
                    this.lblMsg.Text = Resources.Site.TooltipUpdateError;
                }
                else
                {
                    this.lblMsg.ForeColor = Color.Blue;
                    this.lblMsg.Text = Resources.Site.TooltipSaveOK;
                }

            }
        }
Пример #5
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {

                if (Context.User.Identity.IsAuthenticated)
                {
                    AccountsPrincipal user = new AccountsPrincipal(Context.User.Identity.Name);
                    User currentUser = new Maticsoft.Accounts.Bus.User(user);
                    this.lblName.Text = currentUser.UserName;
                    this.lblTruename.Text = currentUser.TrueName;
                    //this.lblSex.Text = currentUser.Sex.Trim() == "1" ? Resources.Site.fieldSexM : Resources.Site.fieldSexF;
                    //this.lblPhone.Text = currentUser.Phone;
                    this.lblEmail.Text = currentUser.Email;
                    lblUserIP.Text = Request.UserHostAddress;
                    //switch(currentUser.Style)
                    //{
                    //    case 1:
                    //        this.lblStyle.Text = "DefaultBlue";
                    //        break;
                    //    case 2:
                    //        this.lblStyle.Text = "Olive";
                    //        break;
                    //    case 3:
                    //        this.lblStyle.Text = "Red";
                    //        break;
                    //    case 4:
                    //        this.lblStyle.Text = "Green";
                    //        break;
                    //}

                }
            }
        }
Пример #6
0
 public User(AccountsPrincipal existingPrincipal)
 {
     this.dataUser = PubConstant.IsSQLServer ? ((IUser) new Maticsoft.Accounts.Data.User()) : ((IUser) new Maticsoft.Accounts.MySqlData.User());
     this.departmentID = "-1";
     this.userID = ((SiteIdentity) existingPrincipal.Identity).UserID;
     DataRow userRow = this.dataUser.Retrieve(this.userID);
     this.LoadFromDR(userRow);
 }
Пример #7
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!Page.IsPostBack)
     {
         if (Context.User.Identity.IsAuthenticated)
         {
             AccountsPrincipal user = new AccountsPrincipal(Context.User.Identity.Name);
             User currentUser = new Maticsoft.Accounts.Bus.User(user);
             this.lblName.Text = currentUser.UserName;
         }
     }
 }
Пример #8
0
        protected void Page_Load(object sender, EventArgs e)
        {
            #region 验证用户

            Maticsoft.Accounts.Bus.User currentUser = null;
            if (Context.User.Identity.IsAuthenticated)
            {
                AccountsPrincipal userPrincipal = new AccountsPrincipal(Context.User.Identity.Name);
                if (Session["UserInfo"] == null)
                {
                    currentUser = new Maticsoft.Accounts.Bus.User(userPrincipal);
                    Session["UserInfo"] = currentUser;
                }
                else
                {
                    currentUser = (Maticsoft.Accounts.Bus.User)Session["UserInfo"];
                }
            }

            if (currentUser != null)
            {
                switch (currentUser.UserType)//UU用户,AA管理员
                {
                    case "AA":
                        loginInfo = "<span>欢迎您,&nbsp;" + currentUser.TrueName + "&nbsp;|&nbsp;</span><span><a href=\"/Admin/Main.htm\">管理中心</a>&nbsp;|&nbsp;</span><span><a href=\"/Logout.aspx\">退出</a></span>";
                        break;

                    case "UU":
                        loginInfo = "<span>欢迎您, &nbsp;" + currentUser.TrueName + "&nbsp;|&nbsp;</span><span><a href=\"/MyAccount/UserCenter.aspx\">我的账户</a>&nbsp;|&nbsp;</span><span><a href=\"/Logout.aspx\">退出</a></span>";
                        break;
                    default:
                        loginInfo = "<span>欢迎您, &nbsp;" + currentUser.TrueName + "&nbsp;|&nbsp;</span><span><a href=\"Logout.aspx\">退出</a></span>";
                        break;
                }
            }

            #endregion 验证用户

            if (!string.IsNullOrEmpty(Request.Params["CourseId"]) && Maticsoft.Common.PageValidate.IsNumber(Request.Params["CourseId"]))
            {
                strCourseID = "?CourseId=" + Request.Params["CourseId"];
            }
            BindList();
            if (!IsPostBack)
            {
            }
        }
Пример #9
0
 private void ShowInfo(int ID)
 {
     AccountsPrincipal existingPrincipal = new AccountsPrincipal(ID);
     User user = new User(existingPrincipal);
     UsersExpModel usersExpModel = new UsersExp().GetUsersExpModel(ID);
     if ((user != null) && (usersExpModel != null))
     {
         this.lblUserName.Text = user.UserName;
         this.lblTrueName.Text = user.TrueName;
         this.lblPhone.Text = user.Phone;
         this.lblNickName.Text = user.NickName;
         this.lblEmail.Text = user.Email;
         this.lblAblums.Text = usersExpModel.AblumsCount.ToString();
         this.lblFans.Text = usersExpModel.FansCount.ToString();
         this.lblFav.Text = usersExpModel.FavouritesCount.ToString();
         this.lblFellows.Text = usersExpModel.FellowCount.ToString();
         this.lblProducts.Text = usersExpModel.ProductsCount.ToString();
         this.lblSex.Text = (!string.IsNullOrWhiteSpace(user.Sex) && (user.Sex.Trim() == "0")) ? "女" : "男";
         this.lblActivity.Text = user.Activity ? "正常使用" : "已经冻结";
         this.lblCreTime.Text = user.User_dateCreate.ToString("yyyy-MM-dd HH:mm:ss");
     }
     if (usersExpModel != null)
     {
         Regions regions = new Regions();
         this.imageGra.ImageUrl = string.Format("/Upload/User/Gravatar/{0}.jpg", usersExpModel.UserID);
         string regionNameByRID = regions.GetRegionNameByRID(Globals.SafeInt(usersExpModel.Address, 0));
         if (regionNameByRID.Contains("北京北京"))
         {
             regionNameByRID = regionNameByRID.Replace("北京北京", "北京");
         }
         else if (regionNameByRID.Contains("上海上海"))
         {
             regionNameByRID = regionNameByRID.Replace("上海上海", "上海");
         }
         else if (regionNameByRID.Contains("重庆重庆"))
         {
             regionNameByRID = regionNameByRID.Replace("重庆重庆", "重庆");
         }
         else if (regionNameByRID.Contains("天津天津"))
         {
             regionNameByRID = regionNameByRID.Replace("天津天津", "天津");
         }
         this.lblAddress.Text = string.IsNullOrEmpty(usersExpModel.Address) ? "暂未设置" : regionNameByRID;
         this.lblPoints.Text = usersExpModel.Points.ToString();
         this.lblLoginDate.Text = usersExpModel.LastLoginTime.ToString("yyyy-MM-dd HH:mm:ss");
     }
 }
Пример #10
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {

                if (Context.User.Identity.IsAuthenticated)
                {
                    AccountsPrincipal user = new AccountsPrincipal(Context.User.Identity.Name);
                    User currentUser = new Maticsoft.Accounts.Bus.User(user);

                    this.lblName.Text = currentUser.UserName;
                    txtTrueName.Text = currentUser.TrueName;
                    //if (currentUser.Sex.Trim().ToUpper() == "1")
                    //    RadioButton1.Checked = true;
                    //else
                    //    RadioButton2.Checked = true;
                    //this.txtPhone.Text = currentUser.Phone;
                    txtEmail.Text = currentUser.Email;

                    //					for(int i=0;i<this.Dropdepart.Items.Count;i++)
                    //					{
                    //						if(this.Dropdepart.Items[i].Value==currentUser.DepartmentID)
                    //						{
                    //							this.Dropdepart.Items[i].Selected=true;
                    //						}
                    //					}

                    //for (int i = 0; i < this.dropUserType.Items.Count; i++)
                    //{
                    //    if (this.dropUserType.Items[i].Value == currentUser.UserType)
                    //    {
                    //        this.dropUserType.Items[i].Selected = true;
                    //    }
                    //}

                    //this.dropStyle.SelectedIndex = currentUser.Style - 1;

                    //					BindRoles(user);

                }

            }
        }
Пример #11
0
        protected void btnSave_Click(object sender, System.EventArgs e)
        {
            string username = this.lblName.Text.Trim();
            AccountsPrincipal user = new AccountsPrincipal(username);
            User currentUser = new Maticsoft.Accounts.Bus.User(user);

            currentUser.UserName = username;
            currentUser.TrueName = txtTrueName.Text.Trim();
            if (txtPassword.Text.Trim() != "")
            {
                currentUser.Password = AccountsPrincipal.EncryptPassword(txtPassword.Text);
            }
            //if (RadioButton1.Checked)
            //    currentUser.Sex = "1";
            //else
            //    currentUser.Sex = "0";

            currentUser.UserType = dropUserType.SelectedValue;
            currentUser.Phone = this.txtPhone.Text.Trim();
            currentUser.Email = txtEmail.Text.Trim();
            if (txtEmployeeID.Text.Length > 0)
            {
                currentUser.EmployeeID = Convert.ToInt32(txtEmployeeID.Text);
            }
            else
            {
                currentUser.EmployeeID = -1;
            }
            currentUser.Activity = !chkActive.Checked;

            //int style = int.Parse(this.dropStyle.SelectedValue);
            //currentUser.Style = style;

            if (!currentUser.Update())
            {
                this.lblMsg.ForeColor = Color.Red;
                this.lblMsg.Text = Resources.Site.TooltipUpdateError;
            }
            else
            {
                Response.Redirect("useradmin.aspx");
            }
        }
Пример #12
0
        public void btnSave_Click(object sender, System.EventArgs e)
        {
            if (Page.IsValid)
            {
                SiteIdentity SID = new SiteIdentity(User.Identity.Name);
                if (SID.TestPassword(txtOldPassword.Text) == 0)
                {
                    this.lblMsg.ForeColor = Color.Red;
                    this.lblMsg.Text = "原密码输入错误!";
                }
                else
                    if (this.txtPassword.Text.Trim() != this.txtPassword1.Text.Trim())
                    {
                        this.lblMsg.ForeColor = Color.Red;
                        this.lblMsg.Text = "密码输入的不一致!请重试!";
                    }
                    else
                    {
                        AccountsPrincipal user = new AccountsPrincipal(Context.User.Identity.Name);
                        User currentUser = new Maticsoft.Accounts.Bus.User(user);

                        currentUser.Password = AccountsPrincipal.EncryptPassword(txtPassword.Text);

                        if (!currentUser.Update())
                        {
                            this.lblMsg.ForeColor = Color.Red;
                            this.lblMsg.Text = Resources.Site.TooltipUpdateError;
                            //日志
                            //UserLog.AddLog(currentUser.UserName, currentUser.UserType, Request.UserHostAddress, Request.Url.AbsoluteUri, "用户密码更新失败");
                        }
                        else
                        {
                            this.lblMsg.ForeColor = Color.Blue;
                            this.lblMsg.Text = Resources.Site.TooltipSaveOK;
                            //日志
                            //UserLog.AddLog(currentUser.UserName, currentUser.UserType, Request.UserHostAddress, Request.Url.AbsoluteUri, "用户密码更新成功");
                        }

                    }
            }
        }
Пример #13
0
 protected void btnSave_Click(object sender, EventArgs e)
 {
     if (this.Page.IsValid)
     {
         string userName = this.lblName.Text.Trim();
         AccountsPrincipal existingPrincipal = new AccountsPrincipal(userName);
         User user = new User(existingPrincipal) {
             UserName = userName,
             TrueName = this.txtTrueName.Text.Trim(),
             Email = this.txtEmail.Text.Trim()
         };
         if (!user.Update())
         {
             MessageBox.ShowFailTip(this, Site.TooltipUpdateError);
         }
         else
         {
             MessageBox.ShowSuccessTip(this, Site.TooltipSaveOK);
         }
     }
 }
Пример #14
0
 public void Page_Load(object sender, EventArgs e)
 {
     if ((!this.Page.IsPostBack && (base.Request.Params["UserID"] != null)) && (base.Request.Params["UserID"] != ""))
     {
         string str = base.Request.Params["UserID"];
         this.lblUserID.Text = str;
         User user = new User(Convert.ToInt32(str));
         DataSet roleList = AccountsTool.GetRoleList();
         this.CheckBoxList1.DataSource = roleList.Tables[0].DefaultView;
         this.CheckBoxList1.DataTextField = "Description";
         this.CheckBoxList1.DataValueField = "RoleID";
         this.CheckBoxList1.DataBind();
         AccountsPrincipal principal = new AccountsPrincipal(user.UserName);
         if (principal.Roles.Count > 0)
         {
             ArrayList roles = principal.Roles;
             for (int i = 0; i < roles.Count; i++)
             {
                 foreach (ListItem item in this.CheckBoxList1.Items)
                 {
                     if (item.Text == roles[i].ToString())
                     {
                         item.Selected = true;
                     }
                 }
             }
         }
         if (!base.UserPrincipal.HasPermissionID(base.GetPermidByActID(this.Act_ShowReservedRole)))
         {
             for (int j = 0; j < this.CheckBoxList1.Items.Count; j++)
             {
                 if (this.ReservedRoleIDs.Contains(this.CheckBoxList1.Items[j].Value))
                 {
                     this.CheckBoxList1.Items.Remove(this.CheckBoxList1.Items[j]);
                 }
             }
         }
     }
 }
Пример #15
0
 protected void btnSubmit_Click(object sender, EventArgs e)
 {
     //检测旧密码是否争取
     string uInput = this.txtOldpws.Value.Trim();
     AccountsPrincipal newUser = AccountsPrincipal.ValidateLogin(CurrentUser.UserName, uInput);
     if (newUser == null)
     {
         Common.MessageBox.ShowFailTip(this, "旧密码错误,请重新输入!");
         return;
     }
     string NewPwd = this.txtSurePwd.Value;
     AccountsPrincipal APUser = new AccountsPrincipal(Context.User.Identity.Name);
     User currentUser = new Maticsoft.Accounts.Bus.User(APUser);
     currentUser.Password = AccountsPrincipal.EncryptPassword(NewPwd);
     if (!currentUser.Update())
     {
         Maticsoft.Common.MessageBox.ShowFailTip(this, "'系统忙,请稍后再试!");
         return;
     }
     else
     {
         Maticsoft.Common.MessageBox.ShowSuccessTip(this, "密码修改成功!下次登录生效!");
     }
 }
Пример #16
0
        //List<int> nodeidlist = new List<int>();
        //public string FavoriteMenu = "";
        //public string ShortcutMenu = "";
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                if (!Context.User.Identity.IsAuthenticated)
                {
                    return;
                }
                user = new AccountsPrincipal(Context.User.Identity.Name);
                if (Session["UserInfo"] != null)
                {

                    currentUser = (Maticsoft.Accounts.Bus.User)Session["UserInfo"];
                   // Maticsoft.BLL.SysManage.TreeFavorite sm = new Maticsoft.BLL.SysManage.TreeFavorite();
                    DataSet ds = sm.GetMenuListByUser(currentUser.UserID);
                    listboxSysManage.DataSource = ds;
                    listboxSysManage.DataTextField = "TreeText";
                    listboxSysManage.DataValueField = "NodeID";
                    listboxSysManage.DataBind();

                }

            }
        }
Пример #17
0
 protected void gridView_RowCommand(object sender, GridViewCommandEventArgs e)
 {
     if ((e.CommandName == "Status") && (e.CommandArgument != null))
     {
         string[] strArray = e.CommandArgument.ToString().Split(new char[] { ',' });
         AccountsPrincipal existingPrincipal = new AccountsPrincipal(Globals.SafeInt(strArray[0], 0));
         User user = new User(existingPrincipal);
         bool flag = Globals.SafeBool(strArray[1], false);
         user.Activity = !flag;
         user.Update();
         this.gridView.OnBind();
     }
 }
Пример #18
0
 private void InitializeComponent()
 {
     if (!MvcApplication.IsInstall)
     {
         base.Response.Write("<script language='javascript'>window.top.location='/Installer/Default.aspx'</script>");
         base.Response.End();
     }
     else
     {
         if (string.IsNullOrWhiteSpace(this.DefaultLoginAdmin))
         {
             throw new ArgumentNullException("SA_Config_System - KEY [DefaultLoginAdmin] IS NULL!");
         }
         if (!this.Context.User.Identity.IsAuthenticated)
         {
             FormsAuthentication.SignOut();
             this.Session.Clear();
             this.Session.Abandon();
             base.Response.Clear();
             base.Response.Write("<script defer>parent.location='" + this.DefaultLoginAdmin + "';</script>");
             base.Response.End();
         }
         else
         {
             this.userPrincipal = new AccountsPrincipal(this.Context.User.Identity.Name);
             if ((this.GetPermidByActID(this.Act_PageLoad) != -1) && !this.userPrincipal.HasPermissionID(this.GetPermidByActID(this.Act_PageLoad)))
             {
                 base.Response.Clear();
                 base.Response.Write("<script defer>window.alert('" + PageBaseMessageTip.TooltipNoPermission + "');history.back();</script>");
                 base.Response.End();
             }
             if (this.Session[Globals.SESSIONKEY_ADMIN] == null)
             {
                 this.currentUser = new User(this.userPrincipal);
                 this.Session[Globals.SESSIONKEY_ADMIN] = this.currentUser;
                 this.Session["Style"] = this.currentUser.Style;
             }
             else
             {
                 this.currentUser = (User) this.Session[Globals.SESSIONKEY_ADMIN];
                 this.Session["Style"] = this.currentUser.Style;
                 if (this.currentUser.UserType != "AA")
                 {
                     FormsAuthentication.SignOut();
                     this.Session.Clear();
                     this.Session.Abandon();
                     base.Response.Clear();
                     base.Response.Write("<script defer>parent.location='" + this.DefaultLoginAdmin + "';</script>");
                     base.Response.End();
                 }
             }
         }
     }
 }
Пример #19
0
 private void BindRoles(AccountsPrincipal user)
 {
     //if (user.Permissions.Count > 0)
     //{
     //    RoleList.Visible = true;
     //    ArrayList Permissions = user.Permissions;
     //    RoleList.Text = "Permissions:<ul>";
     //    for (int i = 0; i < Permissions.Count; i++)
     //    {
     //        RoleList.Text += "<li>" + Permissions[i] + "</li>";
     //    }
     //    RoleList.Text += "</ul>";
     //}
 }
Пример #20
0
        private void InitializeComponent()
        {
            //if (!Page.IsPostBack)
            {

                if (Context.User.Identity.IsAuthenticated)
                {
                    userPrincipal = new AccountsPrincipal(Context.User.Identity.Name);

                    if ((PermissionID != -1) && (!userPrincipal.HasPermissionID(PermissionID)))
                    {
                        Response.Clear();
                        Response.Write("<script defer>window.alert('" + Resources.Site.TooltipNoPermission + "');history.back();</script>");
                        Response.End();
                    }

                    if (Session["UserInfo"] == null)
                    {
                        currentUser = new Maticsoft.Accounts.Bus.User(userPrincipal);
                        Session["UserInfo"] = currentUser;
                        Session["Style"] = currentUser.Style;

                        ////Response.Write("<script defer>location.reload();</script>");
                        ////跳转到 session 超时页面,提示用户重新登录

                        //Response.Clear();
                        //Response.Write("<script defer>window.alert('" + Resources.Site.TooltipSessionExpired + "');parent.location='" + defaullogin + "';</script>");
                        //Response.End();

                    }
                    else
                    {
                        currentUser = (Maticsoft.Accounts.Bus.User)Session["UserInfo"];
                        Session["Style"] = currentUser.Style;
                    }

                }
                else
                {
                    FormsAuthentication.SignOut();
                    Session.Clear();
                    Session.Abandon();
                    Response.Clear();
                    Response.Write("<script defer>window.alert('" + Resources.Site.TooltipNoAuthenticated + "');parent.location='" + defaullogin + "';</script>");
                    Response.End();
                }

            }
        }
        protected override bool AuthorizeCore(HttpContextBase httpContext)
        {
            AccountsPrincipal principal;
            AccountType requiredType = this.RequiredType;
            int permissionId = this.PermissionId;
            if (httpContext == null)
            {
                throw new ArgumentNullException("httpContext");
            }
            if (!httpContext.User.Identity.IsAuthenticated)
            {
                httpContext.Response.StatusCode = 0x321;
                return false;
            }
            if (!Enum.IsDefined(typeof(AccountType), requiredType))
            {
                httpContext.Response.StatusCode = 0x326;
                return false;
            }
            try
            {
                principal = new AccountsPrincipal(httpContext.User.Identity.Name);
            }
            catch (IdentityNotMappedException)
            {
                FormsAuthentication.SignOut();
                if (httpContext.Session != null)
                {
                    httpContext.Session.Remove(Globals.SESSIONKEY_USER);
                    httpContext.Session.Clear();
                    httpContext.Session.Abandon();
                }
                httpContext.Response.StatusCode = 0x321;
                return false;
            }
            User user = null;
            if (httpContext.Session[Globals.SESSIONKEY_USER] == null)
            {
                user = new User(principal);
                httpContext.Session[Globals.SESSIONKEY_USER] = user;
            }
            else
            {
                user = (User) httpContext.Session[Globals.SESSIONKEY_USER];
            }
            if (requiredType != -1)
            {
                switch (user.UserType)
                {
                    case "UU":
                        if (requiredType != AccountType.User)
                        {
                            httpContext.Response.StatusCode = 0x323;
                            return false;
                        }
                        goto Label_01CA;

                    case "AA":
                        if (requiredType != AccountType.Admin)
                        {
                            httpContext.Response.StatusCode = 0x323;
                            return false;
                        }
                        goto Label_01CA;

                    case "EE":
                        if (requiredType != AccountType.Enterprise)
                        {
                            httpContext.Response.StatusCode = 0x323;
                            return false;
                        }
                        goto Label_01CA;

                    case "AG":
                        if (requiredType != AccountType.Agent)
                        {
                            httpContext.Response.StatusCode = 0x323;
                            return false;
                        }
                        goto Label_01CA;
                }
                httpContext.Response.StatusCode = 0x326;
                return false;
            }
        Label_01CA:
            if ((permissionId != -1) && !principal.HasPermissionID(permissionId))
            {
                httpContext.Response.StatusCode = 0x323;
                return false;
            }
            return true;
        }
Пример #22
0
        protected void Page_Load(object sender, EventArgs e)
        {
            Title = "定制菜单";
            if (!Page.IsPostBack)
            {
                if (!Context.User.Identity.IsAuthenticated)
                {
                    return;
                }
                user = new AccountsPrincipal(Context.User.Identity.Name);
                if (Session["UserInfo"] != null)
                {
                    currentUser = (Maticsoft.Accounts.Bus.User)Session["UserInfo"];
                    nodeidlist = tfbll.GetNodeIDsByUser(currentUser.UserID);

                    DataSet ds = smbll.GetTreeSonList(0,UserPrincipal.PermissionsID);
                    listMenus.DataSource = ds;
                    listMenus.DataBind();
                }
            }
        }
Пример #23
0
 private void InitializeComponent()
 {
     if (Context.User.Identity.IsAuthenticated)
     {
         userPrincipal = new AccountsPrincipal(Context.User.Identity.Name);
         if (Session["UserInfo"] == null)
         {
             currentUser = new Maticsoft.Accounts.Bus.User(userPrincipal);
             Session["UserInfo"] = currentUser;
             Session["Style"] = currentUser.Style;
         }
         else
         {
             currentUser = (Maticsoft.Accounts.Bus.User)Session["UserInfo"];
             Session["Style"] = currentUser.Style;
         }
     }
 }
Пример #24
0
 public virtual void InitializeComponent()
 {
     if (this.Context.User.Identity.IsAuthenticated)
     {
         this.userPrincipal = new AccountsPrincipal(this.Context.User.Identity.Name);
         if (this.Session[Globals.SESSIONKEY_ADMIN] == null)
         {
             this.currentUser = new User(this.userPrincipal);
             this.Session[Globals.SESSIONKEY_ADMIN] = this.currentUser;
             this.Session["Style"] = this.currentUser.Style;
         }
         else
         {
             this.currentUser = (User) this.Session[Globals.SESSIONKEY_ADMIN];
             this.Session["Style"] = this.currentUser.Style;
         }
     }
 }