コード例 #1
0
    public static Model_Users AdminAppAuthLogin(Page p)
    {
        Model_Users u = null;



        if (HttpContext.Current.Request.Cookies["SessionKey"] != null)
        {
            HttpCookie objCookie = new HttpCookie("SessionKey");
            //objCookie.Domain = "www.hotels2thailand.com";
            objCookie.Expires = DateTime.Now.AddDays(-1d);
            HttpContext.Current.Response.Cookies.Add(objCookie);


            Model_Session ms        = new Model_Session();
            int           intLogKey = int.Parse(HttpContext.Current.Request.Cookies["SessionKey"]["LogKey"]);
            ms = ms.IsHaveSessionRecord(intLogKey);
            if (ms != null)
            {
                u = UsersController.GetUserbyID(ms.UserID);
                if (u != null && !ms.LeaveTime.HasValue)
                {
                    HttpContext.Current.Response.Redirect("~/admin/");
                }
            }
        }



        return(u);
    }
コード例 #2
0
    public static bool UpdateSessionLogout(int intSesstionId)
    {
        Model_Session ms = new Model_Session
        {
            UserSessionID = intSesstionId
        };

        return(ms.UpdateSessionAuthorizeLogOut(ms));
    }
コード例 #3
0
    public static bool UpdateSessionStatus(int intSesstionId)
    {
        Model_Session clStaffSession = new Model_Session
        {
            UserSessionID = intSesstionId,
        };

        return(clStaffSession.UpdateSessionAuthorize(clStaffSession));
    }
コード例 #4
0
    public static void SessionCreateUserFront(Model_Users Users)
    {
        HttpSessionState Hotels2Session = HttpContext.Current.Session;

        Hotels2Session["UserFront"] = Users.UserCatId;

        Model_Session ms = new Model_Session();

        int Key = ms.InsertUserToSesstionRecord(Users);

        //creat Cookie for Reference user Login Life Time
        CreateCookieSessionFront(Key);

        HttpContext.Current.Response.Redirect("~/");
    }
コード例 #5
0
    public string UserStatus()
    {
        StringBuilder ret = new StringBuilder();

        if (Session["staff"] != null)
        {
            Model_Session ms = new Model_Session();
            ms = ms.IsHaveSessionRecord(UserSessionController.CurrentCookieLog);


            ret.Append("<span class=\"clear\"> <span class=\"block m-t-xs\"> <strong class=\"font-bold\">Welcome " + ms.FirstName + " </strong>");
            ret.Append("</span> <span class=\"text-muted text-xs block\">" + ms.UserRoleName + " <b class=\"caret\"></b></span> </span> </a>");
        }

        return(ret.ToString());
    }
コード例 #6
0
    public static Model_Users AdminAppAuthorization(Page p)
    {
        Model_Users      u = null;
        HttpSessionState Hotels2Session = HttpContext.Current.Session;
        //object objSession = HttpContext.Current.Session["staff"];
        HttpCookie    objCookie = HttpContext.Current.Request.Cookies["SessionKey"];
        Model_Session ms        = new Model_Session();

        object objSession = Hotels2Session["staff"];
        int    intLogKey  = 0;


        if (objSession == null && objCookie == null)
        {
            //HttpContext.Current.Response.Redirect("~/admin/accessdenie.aspx?error=requestlogin_111");
            HttpContext.Current.Response.Redirect("~/admin/login");
            HttpContext.Current.Response.End();
        }


        if (objSession != null && objCookie == null)
        {
            //HttpContext.Current.Response.Redirect("~/admin/accessdenie.aspx?error=requestlogin_444");
            HttpContext.Current.Response.Redirect("~/admin/login");
            HttpContext.Current.Response.End();
        }

        if (objCookie != null)
        {
            intLogKey = int.Parse(objCookie["LogKey"]);
            ms        = ms.IsHaveSessionRecord(intLogKey);


            if (ms == null)
            {
                //HttpContext.Current.Response.Redirect("~/admin/accessdenie.aspx?error=requestlogin_333");
                HttpContext.Current.Response.Redirect("~/admin/login");
                HttpContext.Current.Response.End();
            }


            u = UsersController.GetUserbyID(ms.UserID);

            if (!u.Status)
            {
                LogoutStaffNotActivate();
            }

            if (ms.LeaveTime.HasValue)
            {
                //string message = "AccessKey: " + intLogKey + " SessionStaffValue:" + objSession + " LeaveTime: " + (!clStaffSesssion.LeaveTime.HasValue ? "NULL" : ((DateTime)clStaffSesssion.LeaveTime).ToString());
                //try
                //{
                //    Hotels2thailand.Hotels2MAilSender.Sendmail("*****@*****.**", "Booking2Staff Error", "*****@*****.**", "StaffLogin Fail:access denided from bht staff with empty leavtime", "", message);
                //}
                //catch { }


                //objLog.WriteLog(EnumCodeLog.ServiceUnavailable, EnumLevelLog.Error, "StaffLogin", message, null);

                //HttpContext.Current.Response.Redirect("~/admin/accessdenie.aspx?error=requestlogin_222");



                HttpContext.Current.Response.Redirect("~/admin/login");
                HttpContext.Current.Response.End();
            }


            Hotels2Session["staff"] = u.UserCatId.ToString();
            UpdateSessionStatus(intLogKey);


            //if (!IsAuthorizePage(u, ConfigurationManager.AppSettings["AuthorizeBaseURL"].ToString()))
            //{

            //    try
            //    {
            //        HttpContext.Current.Response.Redirect(HttpContext.Current.Request.UrlReferrer.ToString() + "#accessdinied");
            //    }
            //    catch
            //    {
            //        HttpContext.Current.Response.Redirect(HttpContext.Current.Request.Url.ToString() + "#accessdinied");
            //    }

            //    HttpContext.Current.Response.End();

            //}
        }
        return(u);
    }
コード例 #7
0
    public static void CloseOtherCurrentLogin(int UserID)
    {
        Model_Session ms = new Model_Session();

        int Key = ms.CloseOtherCurrentLogin(UserID);
    }
コード例 #8
0
    public static Model_Users FrontAppAuthorization(Page p)
    {
        Model_Users      u = null;
        HttpSessionState Hotels2Session = HttpContext.Current.Session;
        //object objSession = HttpContext.Current.Session["staff"];
        HttpCookie    objCookie = HttpContext.Current.Request.Cookies["SessionKeyFront"];
        Model_Session ms        = new Model_Session();

        object objSession = Hotels2Session["UserFront"];
        int    intLogKey  = 0;


        if (objSession == null && objCookie == null)
        {
            //HttpContext.Current.Response.Redirect("~/admin/accessdenie.aspx?error=requestlogin_111");
            HttpContext.Current.Response.Redirect("~/Login");
            HttpContext.Current.Response.End();
        }


        if (objSession != null && objCookie == null)
        {
            //HttpContext.Current.Response.Redirect("~/admin/accessdenie.aspx?error=requestlogin_444");
            HttpContext.Current.Response.Redirect("~/Login");
            HttpContext.Current.Response.End();
        }

        if (objCookie != null)
        {
            intLogKey = int.Parse(objCookie["LogKeyFront"]);
            ms        = ms.IsHaveSessionRecord(intLogKey);


            if (ms == null)
            {
                //HttpContext.Current.Response.Redirect("~/admin/accessdenie.aspx?error=requestlogin_333");
                HttpContext.Current.Response.Redirect("~/Login");
                HttpContext.Current.Response.End();
            }


            u = UsersController.GetUserbyID(ms.UserID);


            if (u.UserCatId != 1)
            {
                HttpContext.Current.Response.Redirect("~/Login");
                HttpContext.Current.Response.End();
            }

            if (!u.Status)
            {
                LogoutStaffNotActivateFront();
            }

            if (ms.LeaveTime.HasValue)
            {
                HttpContext.Current.Response.Redirect("~/Login");
                HttpContext.Current.Response.End();
            }


            Hotels2Session["UserFront"] = u.UserCatId.ToString();
            UpdateSessionStatus(intLogKey);
        }

        if (!u.EmailVerify)
        {
            string   url    = HttpContext.Current.Request.Url.AbsoluteUri;
            string[] arrurl = url.Split('/');
            int      length = arrurl.Length;

            string route = arrurl[length - 1];

            route = route.Split('?')[0];
            if (route != "" && route.ToLower() != "default.aspx" && route.ToLower() != "default")
            {
                HttpContext.Current.Response.Redirect("/");
            }
        }


        return(u);
    }