예제 #1
0
        /// <summary>
        /// The first action check when form load
        /// - Validate only allow Common user
        /// </summary>
        protected void FirstLoad()
        {
            var isCurrentUserInCommonGroup = false;

            if (Page.Session[SessionKey.IsCurrentUserInCommonGroup] != null)
            {
                bool.TryParse(Page.Session[SessionKey.IsCurrentUserInCommonGroup].ToString(), out isCurrentUserInCommonGroup);
            }
            else
            {
                isCurrentUserInCommonGroup = UserPermission.IsCurrentUserInGroup(StringConstant.CommonAccounts);
                Page.Session[SessionKey.IsCurrentUserInCommonGroup] = isCurrentUserInCommonGroup;
            }

            // Check and only allow Common user
            //if (!UserPermission.IsCurrentUserInGroup(StringConstant.CommonAccounts) || SPContext.Current.Web.CurrentUser.IsSiteAdmin)
            if (!isCurrentUserInCommonGroup || SPContext.Current.Web.CurrentUser.IsSiteAdmin)
            {
                // Is AD or System Account
                //Response.Redirect(StringConstant.PageOverviewURL);
                SPUtility.Redirect(StringConstant.PageOverviewURL, SPRedirectFlags.DoNotEndResponse | SPRedirectFlags.Trusted, HttpContext.Current);
            }
            else
            {
                // Is Common User
                // Check Logged in
                var employeeInfo = UserPermission.GetEmployeeInfo();
                if (employeeInfo != null)
                {
                    // Have not logged in -> Redirect to Login Page
                    //Response.Redirect(StringConstant.PageOverviewURL);
                    SPUtility.Redirect(StringConstant.PageOverviewURL, SPRedirectFlags.DoNotEndResponse | SPRedirectFlags.Trusted, HttpContext.Current);
                }
            }
        }
예제 #2
0
        /// <summary>
        /// Process submit action
        /// 1. Get data from layout
        /// 2. Validate -> show error message?
        /// 3. Check Login
        /// </summary>
        protected void OnVerify()
        {
            // 1. Get data from layout
            // 2. Validate -> show error message?
            // 3. Check Login -> Redirect to Overview Page or show error message?
            var model = GetDataFromLayout();

            if (!Page.IsValid)
            {
                return;
            }
            bool isSuccess = CheckLogin(model);

            if (isSuccess)
            {
                // Store session IsManager
                bool isManager = !UserPermission.IsCurrentUserInGroup(StringConstant.CommonAccounts);
                HttpContext.Current.Session[StringConstant.IsAdmin] = isManager;

                // Redirect to Overview Page
                Response.Redirect(StringConstant.PageOverviewURL);
            }
            else
            {
                NotificationStatusHelper.SetErrorStatus(Page.Form, WebPageResourceHelper.GetResourceString(StringConstant.ResourcekeyGeneralTitleError), WebPageResourceHelper.GetResourceString(StringConstant.ResourcesKeyLoginMessageFail));
            }
        }
        /// <summary>
        ///     Load data
        /// </summary>
        /// <returns>model in form</returns>
        protected void LoadData()
        {
            var isCurrentUserInCommonGroup = false;

            if (Page.Session[SessionKey.IsCurrentUserInCommonGroup] != null)
            {
                bool.TryParse(Page.Session[SessionKey.IsCurrentUserInCommonGroup].ToString(), out isCurrentUserInCommonGroup);
            }
            else
            {
                isCurrentUserInCommonGroup = UserPermission.IsCurrentUserInGroup(StringConstant.CommonAccounts);
                Page.Session[SessionKey.IsCurrentUserInCommonGroup] = isCurrentUserInCommonGroup;
            }

            // if (!SPContext.Current.Web.CurrentUser.IsSiteAdmin && UserPermission.IsCurrentUserInGroup(StringConstant.CommonAccounts))
            if (!SPContext.Current.Web.CurrentUser.IsSiteAdmin && isCurrentUserInCommonGroup)
            {
                var employeeInfo = UserPermission.GetEmployeeInfo();

                // Common user alreay logged in
                if (employeeInfo != null)
                {
                    EmployeeNameLiteral.Text = employeeInfo.FullName;
                    ScriptManager.RegisterStartupScript(this, GetType(), "ShowWelcomeCommon", "showWelcomeCommon();", true);
                    employeeInfo.Image = string.Empty;
                    this._employeeInfo = employeeInfo;
                }
                else
                {
                    ScriptManager.RegisterStartupScript(this, GetType(), "hideWelcomeCommon", "hideWelcomeCommon();", true);
                }
            }
            else
            {
                try
                {
                    var employee = Page.Session[WelcomeCommonUser_EmployeeInfo_Session_Key] as EmployeeInfo;

                    if (employee == null)
                    {
                        EmployeeInfoDAL employeeInfoDAL = new EmployeeInfoDAL(SPContext.Current.Site.Url);
                        //DepartmentDAL departmentDAL = new DepartmentDAL(SPContext.Current.Site.Url);
                        employee = employeeInfoDAL.GetByADAccount(SPContext.Current.Web.CurrentUser.ID);
                        if (employee != null)
                        {
                            employee.Image     = string.Empty;
                            this._employeeInfo = employee;
                            Page.Session[WelcomeCommonUser_EmployeeInfo_Session_Key] = employee;
                        }
                    }
                    else
                    {
                        this._employeeInfo = employee;
                    }
                }
                catch { }

                ScriptManager.RegisterStartupScript(this, GetType(), "showWelcome", "showWelcome();", true);
            }
        }
예제 #4
0
 /// <summary>
 /// The first action check when form load
 /// - Validate only allow Common user
 /// </summary>
 protected void FirstLoad()
 {
     // Check and only allow Common user
     if (!UserPermission.IsCurrentUserInGroup(StringConstant.CommonAccounts) || (SPContext.Current.Web.CurrentUser.ID == SPContext.Current.Site.SystemAccount.ID))
     {
         // Is AD or System Account
         Response.Redirect(StringConstant.PageOverviewURL);
     }
     else
     {
         // Is Common User
         // Check Logged in
         var employeeInfo = UserPermission.GetEmployeeInfo();
         if (employeeInfo == null)
         {
             // Have not logged in -> Redirect to Login Page
             Response.Redirect(StringConstant.PageLoginURL);
         }
         else
         {
             // Logged in -> Allow access page
             // Load and update data to layout
             var model = LoadData();
             UpdateDataToLayout(model);
         }
     }
 }
예제 #5
0
 /// <summary>
 /// The first action check when form load
 /// - Validate only allow IT Members + System Account
 /// </summary>
 protected void FirstLoad()
 {
     // Check and only allow IT Members + Contributors + System Account// System admin
     if (UserPermission.IsCurrentUserInGroup(StringConstant.ITMembers) || UserPermission.IsCurrentUserInGroup(StringConstant.ITContributors) || UserPermission.IsCurrentUserInGroup(StringConstant.SystemAdmin) || (SPContext.Current.Web.CurrentUser.ID == SPContext.Current.Site.SystemAccount.ID))
     {
         // Load and update data to layout
         var model = LoadData();
         UpdateDataToLayout(model);
     }
     else
     {
         // Not allow access page => return to Overview
         Response.Redirect(SPContext.Current.Web.Url + StringConstant.PageOverviewURL);
     }
 }
예제 #6
0
 private void CheckCurrentUser(string currentWebURL, int departmentId)
 {
     if (UserPermission.IsCurrentUserInGroup(StringConstant.BOD))
     {
         isBOD = true;
     }
     else
     {
         var currentDepartment = DepartmentListSingleton.GetDepartmentByID(departmentId, currentWebURL);
         if (currentDepartment != null)
         {
             if (currentDepartment.Code == HR_DEPARTMENT_CODE)
             {
                 isBOD = false;
             }
         }
     }
 }
예제 #7
0
        protected void Page_Load(object sender, EventArgs e)
        {
            SPWeb currentWeb = SPContext.Current.Web;

            if (currentWeb.Name.ToLower().Equals("policies") || currentWeb.ServerRelativeUrl.ToLower().Equals("/policies"))
            {
                return;
            }

            Page.Response.Cache.SetCacheability(System.Web.HttpCacheability.NoCache);
            SPUser currentUser = currentWeb.CurrentUser;

            var currentPage = Request.CurrentExecutionFilePath;

            PermissionGroupDAL = new PermissionGroupDAL(SPContext.Current.Site.RootWeb.Url);
            var groups = new List <string>();

            var items = currentWeb.CurrentUser.Groups.GetEnumerator();

            while (items.MoveNext())
            {
                groups.Add(items.Current.ToString());
            }

            var hasPermission = PermissionGroupDAL.IsAuthorizedOnPage(SPContext.Current.Site.RootWeb, currentPage, groups);

            if (!hasPermission)
            {
                var ex = new SecurityException();
                SPUtility.HandleAccessDenied(ex);
            }

            if (currentUser.IsSiteAdmin == false && UserPermission.IsCurrentUserInGroup(StringConstant.Group.CommonAccountGroupName) && HttpContext.Current.Session[StringConstant.EmployeeLogedin] == null)
            {
                string url = HttpContext.Current.Request.Url.AbsoluteUri;
                if (url.Contains(StringConstant.PageLoginURL) || url.Contains(StringConstant.PageHomeURL))
                {
                    return;
                }
                Response.Redirect(StringConstant.PageLoginURL);
            }
        }
예제 #8
0
 /// <summary>
 /// The first action check when form load
 /// - Validate only allow Common user
 /// </summary>
 protected void FirstLoad()
 {
     // Check and only allow Common user
     if (!UserPermission.IsCurrentUserInGroup(StringConstant.CommonAccounts) || SPContext.Current.Web.CurrentUser.IsSiteAdmin)
     {
         // Is AD or System Account
         Response.Redirect(StringConstant.PageOverviewURL);
     }
     else
     {
         // Is Common User
         // Check Logged in
         var employeeInfo = UserPermission.GetEmployeeInfo();
         if (employeeInfo != null)
         {
             // Have not logged in -> Redirect to Login Page
             Response.Redirect(StringConstant.PageOverviewURL);
         }
     }
 }
 private void CheckCurrentUser(string currentWebURL)
 {
     if (UserPermission.IsCurrentUserInGroup(StringConstant.BOD))
     {
         isBOD = true;
     }
     else
     {
         UserHelper userHelper        = new UserHelper();
         var        currentEmployee   = userHelper.GetCurrentLoginUser();
         var        currentDepartment = DepartmentListSingleton.GetDepartmentByID(currentEmployee.Department.LookupId, currentWebURL);
         if (currentDepartment != null)
         {
             if (currentDepartment.Code == HR_DEPARTMENT_CODE)
             {
                 isBOD = false;
             }
         }
     }
 }
예제 #10
0
        protected void Page_Load(object sender, EventArgs e)
        {
            bool isAdminDepartment = UserPermission.IsAdminDepartment;
            bool isBOD             = UserPermission.IsCurrentUserInGroup(StringConstant.BOD);

            XElement xmlViewDef    = XElement.Parse(ShiftRequestDepartmentWebPart.XmlDefinition);
            string   selectedDepId = this.Page.Request.Params.Get("AdminDeptId");
            XElement filterElement = BuildViewString(isBOD, isAdminDepartment, selectedDepId);

            XElement whereElement = xmlViewDef.Descendants("Where").FirstOrDefault();

            if (whereElement != null)
            {
                if (whereElement.HasElements)
                {
                    whereElement.RemoveNodes();
                }
                whereElement.Add(filterElement);
                ShiftRequestDepartmentWebPart.XmlDefinition = xmlViewDef.ToString();
            }
        }
예제 #11
0
        /// <summary>
        /// Process submit action
        /// 1. Get data from layout
        /// 2. Validate -> show error message?
        /// 3. Check Login
        /// </summary>
        protected void OnVerify()
        {
            // 1. Get data from layout
            // 2. Validate -> show error message?
            // 3. Check Login -> Redirect to Overview Page or show error message?
            var model = GetDataFromLayout();

            if (!Page.IsValid)
            {
                return;
            }
            bool isSuccess = CheckLogin(model);

            if (isSuccess)
            {
                var isCurrentUserInCommonGroup = false;
                if (Page.Session[SessionKey.IsCurrentUserInCommonGroup] != null)
                {
                    bool.TryParse(Page.Session[SessionKey.IsCurrentUserInCommonGroup].ToString(), out isCurrentUserInCommonGroup);
                }
                else
                {
                    isCurrentUserInCommonGroup = UserPermission.IsCurrentUserInGroup(StringConstant.CommonAccounts);
                    Page.Session[SessionKey.IsCurrentUserInCommonGroup] = isCurrentUserInCommonGroup;
                }

                // Store session IsManager
                //bool isManager = !UserPermission.IsCurrentUserInGroup(StringConstant.CommonAccounts);
                bool isManager = !isCurrentUserInCommonGroup;
                HttpContext.Current.Session[StringConstant.IsAdmin] = isManager;

                // Redirect to Overview Page
                //Response.Redirect(StringConstant.PageOverviewURL);
                SPUtility.Redirect(StringConstant.PageOverviewURL, SPRedirectFlags.DoNotEndResponse | SPRedirectFlags.Trusted, HttpContext.Current);
            }
            else
            {
                NotificationStatusHelper.SetErrorStatus(Page.Form, WebPageResourceHelper.GetResourceString(StringConstant.ResourcekeyGeneralTitleError), WebPageResourceHelper.GetResourceString(StringConstant.ResourcesKeyLoginMessageFail));
            }
        }
예제 #12
0
        /// <summary>
        ///     Load data
        /// </summary>
        /// <returns>model in form</returns>
        protected void LoadData()
        {
            if (!SPContext.Current.Web.CurrentUser.IsSiteAdmin && UserPermission.IsCurrentUserInGroup(StringConstant.CommonAccounts))
            {
                var employeeInfo = UserPermission.GetEmployeeInfo();

                // Common user alreay logged in
                if (employeeInfo != null)
                {
                    EmployeeNameLiteral.Text = employeeInfo.FullName;
                    ScriptManager.RegisterStartupScript(this, GetType(), "ShowWelcomeCommon", "showWelcomeCommon();", true);
                    employeeInfo.Image = string.Empty;
                    this._employeeInfo = employeeInfo;
                }
                else
                {
                    ScriptManager.RegisterStartupScript(this, GetType(), "hideWelcomeCommon", "hideWelcomeCommon();", true);
                }
            }
            else
            {
                try
                {
                    EmployeeInfoDAL employeeInfoDAL = new EmployeeInfoDAL(SPContext.Current.Site.Url);
                    //DepartmentDAL departmentDAL = new DepartmentDAL(SPContext.Current.Site.Url);
                    var employee = employeeInfoDAL.GetByADAccount(SPContext.Current.Web.CurrentUser.ID);
                    if (employee != null)
                    {
                        employee.Image     = string.Empty;
                        this._employeeInfo = employee;
                    }
                }
                catch { }

                ScriptManager.RegisterStartupScript(this, GetType(), "showWelcome", "showWelcome();", true);
            }
        }