示例#1
0
        // User Login on Site
        public void Add_UserCookie(Page myPage, string Email, string Password, bool RememberMe)
        {
            MySQL_DataConn myDP = new MySQL_DataConn(ConfigurationManager.ConnectionStrings["e2CMS"].ConnectionString);

            HttpCookie cookieUserInfo = new HttpCookie("UserInfo");

            // Add Value
            cookieUserInfo["Email"]      = Email;
            cookieUserInfo["Password"]   = Password;
            cookieUserInfo["RememberMe"] = RememberMe.ToString();

            Login_Users myLogin_User = new Login_Users(myDP.Get_UserDetail_ByEmail(Email, "0", "0"));

            // Add UserInfo to Coookie
            cookieUserInfo["UserID"]   = myLogin_User.UserID;
            cookieUserInfo["Username"] = myLogin_User.UserName;

            // Add Misc
            cookieUserInfo.Domain = ConfigurationManager.AppSettings["Cookie_Domain"];
            //cookieUserInfo.Path = "/";

            if (RememberMe)
            {
                cookieUserInfo.Expires = DateTime.Now.AddDays(30);
            }
            else
            {
                cookieUserInfo.Expires = DateTime.Now.AddDays(1);
            }

            myPage.Response.Cookies.Add(cookieUserInfo);
        }
示例#2
0
        public static string Get_UserNameByID(string UserID)
        {
            MySQL_DataConn myDP = new MySQL_DataConn(ConfigurationManager.ConnectionStrings["e2CMS"].ConnectionString);

            Login_Users myLogin_User = new Login_Users(myDP.Get_UserDetail_ByUserID(UserID, "ALL", "ALL"));

            return(myLogin_User.UserName);
        }
示例#3
0
        public static bool Validate_UserGroup(Page myPage, UserGroup myUserGroup)
        {
            MySQL_DataConn myDP = new MySQL_DataConn(ConfigurationManager.ConnectionStrings["e2CMS"].ConnectionString);

            UserMgr myUserMgr = new UserMgr();

            Login_Users myUsers = myUserMgr.Get_Login_Users(myPage);

            return(myDP.Chk_UserInGroup(myUsers.UserID, StringEnum.GetStringValue(myUserGroup)));
        }
示例#4
0
        public static string Current_UserName(Page myPage)
        {
            UserMgr myUserMgr = new UserMgr();

            Login_Users myUsers = myUserMgr.Get_Login_Users(myPage);

            if (myUsers != null)
            {
                return(myUsers.UserName);
            }
            else
            {
                return("Guest");
            }
        }
示例#5
0
        public static bool Validate_PageAuth_View(Page myPage, string PageIndexID)
        {
            Pages.PrivacyMgr myPrivacyMgr = new Pages.PrivacyMgr();

            string _pageindexid = myPrivacyMgr.Get_Inherited_Privacy_PageIndexID(PageIndexID);

            // Check Guest User first
            Pages.Page_Privacy Guest_Privacy = myPrivacyMgr.Get_Page_Privacy(_pageindexid, StringEnum.GetStringValue(UserGroup.Guest));

            if (Guest_Privacy == null)
            {
                // If Guest permission didn't set permission is allowed.
                return(true);
            }
            else
            {
                if (Guest_Privacy.Allow_View)
                {
                    return(true);
                }
            }

            // Check logged in user.
            UserMgr     myUserMgr = new UserMgr();
            Login_Users myUsers   = myUserMgr.Get_Login_Users(myPage);

            if (myUsers != null)
            {
                // User has logged in
                List <UserInGroups> myUserInGroups = myUserMgr.Get_UserIngroups_ByUserID(myUsers.UserID);

                foreach (UserInGroups myUserInGroup in myUserInGroups)
                {
                    Pages.Page_Privacy myPage_Privacy = myPrivacyMgr.Get_Page_Privacy(_pageindexid, myUserInGroup.UserGroupID);

                    if (myPage_Privacy != null)
                    {
                        if (myPage_Privacy.Allow_View)
                        {
                            return(true);
                        }
                    }
                }
            }

            return(false);
        }
示例#6
0
        public static bool Validate_PageAuth_Modify(Page myPage)
        {
            Pages.PrivacyMgr myPrivacyMgr = new Pages.PrivacyMgr();

            string _pageindexid = myPrivacyMgr.Get_Inherited_Privacy_PageIndexID(myPage.Request["PageIndexID"]);

            // Check Guest User first
            Pages.Page_Privacy Guest_Privacy = myPrivacyMgr.Get_Page_Privacy(_pageindexid, StringEnum.GetStringValue(UserGroup.Guest));

            if (Guest_Privacy != null)
            {
                if (Guest_Privacy.Allow_Modify)
                {
                    return(true);
                }
            }

            // Check logged in user.
            UserMgr     myUserMgr = new UserMgr();
            Login_Users myUsers   = myUserMgr.Get_Login_Users(myPage);

            if (myUsers != null)
            {
                // User has logged in
                List <UserInGroups> myUserInGroups = myUserMgr.Get_UserIngroups_ByUserID(myUsers.UserID);

                foreach (UserInGroups myUserInGroup in myUserInGroups)
                {
                    Pages.Page_Privacy myPage_Privacy = myPrivacyMgr.Get_Page_Privacy(_pageindexid, myUserInGroup.UserGroupID);

                    if (myPage_Privacy != null)
                    {
                        if (myPage_Privacy.Allow_Modify)
                        {
                            return(true);
                        }
                    }
                }
            }

            return(false);
        }
示例#7
0
        public static bool Validate_Ownership(Page myPage, string Ownership_UserID)
        {
            UserMgr myUserMgr = new UserMgr();

            Login_Users myUsers = myUserMgr.Get_Login_Users(myPage);

            if (myUsers != null)
            {
                if (myUsers.UserID == Ownership_UserID)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            else
            {
                return(false);
            }
        }