Ejemplo n.º 1
0
        /// <summary>
        /// Check if user has privilege
        /// </summary>
        /// <param name="privilege"></param>
        /// <returns></returns>
        public static bool HasPrivilege(string privilege, HttpContext httpContext = null)
        {
            if (httpContext == null)
            {
                httpContext = HttpContext.Current ?? null;
            }

            if (httpContext == null || !httpContext.User.Identity.IsAuthenticated || httpContext.Session[SessionHelper.UserData] == null)
            {
                return(false);
            }

            List <RolePrivilege> privileges;

            if (httpContext.Session[SessionHelper.PrivilegeForUser] == null)
            {
                var user = ( UserAccount )httpContext.Session[SessionHelper.UserData];
                privileges = (UserAccountServiceFacade.GetRolePrivileges(user.UserAccountId)).ToList();
                httpContext.Session[SessionHelper.PrivilegeForUser] = privileges;
            }
            else
            {
                privileges = (List <RolePrivilege>)httpContext.Session[SessionHelper.PrivilegeForUser];
            }

            return(privileges != null && privileges.Any(p => p.Name != null && p.Name.Trim().ToLower() == privilege.Trim().ToLower()));
        }
Ejemplo n.º 2
0
        public ActionResult IndexCompleted()
        {
            if (!User.Identity.IsAuthenticated)
            {
                return(RedirectToAction("SignOut", "Home", new { redirect = this.HttpContext.Request.RawUrl }));
            }


            Session[SessionHelper.DisplaySystemAdmin] = null;
            Session[SessionHelper.SearchTerm]         = null;

            UserAccount user = null;

            ViewBag.Title = "Loan Center";
            if (Session[SessionHelper.UserData] != null && (( UserAccount )Session[SessionHelper.UserData]).Username == User.Identity.Name)
            {
                user = ( UserAccount )Session[SessionHelper.UserData];
            }
            else
            {
                user = UserAccountServiceFacade.GetUserByName(User.Identity.Name);
            }

            if (user != null)
            {
                LoginHelper loginHelper = new LoginHelper();
                loginHelper.SetBranding(user);

                Session[SessionHelper.UserData] = user;

                if (!AccountHelper.IsInRole(RoleName.Administrator) && !AccountHelper.IsInRole(RoleName.Hvm))
                {
                    // Show only records where user is assigned to (either if it's as LO/Concierge, LOA or Loan Processor )
                    Session[SessionHelper.UserAccountIds] = new List <int> {
                        user.UserAccountId
                    };
                }
                else
                {
                    // Don't filter result list
                    Session[SessionHelper.UserAccountIds] = null;
                }
            }

            if (Session[SessionHelper.PrivilegeForReviewPreApprovalQueue] == null || Session[SessionHelper.PrivilegeForManagingQueues] == null ||
                Session[SessionHelper.PrivilegeForManagingAppraisalOrders] == null || Session[SessionHelper.DisplayAppraisalQueues] == null)
            {
                List <RolePrivilege> privileges = (UserAccountServiceFacade.GetRolePrivileges(user.UserAccountId)).ToList();
                Session[SessionHelper.PrivilegeForUser] = privileges;

                Session[SessionHelper.PrivilegeForReviewPreApprovalQueue] = false;
                if (privileges != null && (privileges.Any(p => p.Category == ( int )ActionCategory.ReviewPreApprovalQueue)))
                {
                    Session[SessionHelper.PrivilegeForReviewPreApprovalQueue] = true;
                }
                else
                {
                    Session[SessionHelper.PrivilegeForReviewPreApprovalQueue] = false;
                }

                if (privileges.Any(p => p.Category == ( int )ActionCategory.ManagingQueues))
                {
                    Session[SessionHelper.PrivilegeForManagingQueues] = true;
                }
                else
                {
                    Session[SessionHelper.PrivilegeForManagingQueues] = false;
                }

                if (privileges.Any(p => p.Name.Trim().Equals(PrivilegeName.DisplayAppraisalQueues)))
                {
                    Session[SessionHelper.DisplayAppraisalQueues] = true;
                }
                else
                {
                    Session[SessionHelper.DisplayAppraisalQueues] = false;
                }

                if (privileges.Any(p => p.Name.Trim().Equals(PrivilegeName.ViewQueuesFilter)))
                {
                    Session[SessionHelper.ViewQueuesFilter] = true;
                }
                else
                {
                    Session[SessionHelper.ViewQueuesFilter] = false;
                }

                if (privileges.Any(p => p.Name.Trim().Equals(PrivilegeName.ViewSystemAdmin)))
                {
                    Session[SessionHelper.PrivilegeForViewSystemAdmin] = true;
                }
                else
                {
                    Session[SessionHelper.PrivilegeForViewSystemAdmin] = false;
                }

                if (privileges.Any(p => p.Name.Trim().Equals(PrivilegeName.ViewConciergeHome)))
                {
                    Session[SessionHelper.PrivilegeForViewConciergeCenter] = true;
                }
                else
                {
                    Session[SessionHelper.PrivilegeForViewConciergeCenter] = false;
                }

                if (privileges.Any(p => p.Name.Trim().Equals(PrivilegeName.ViewLoanCenter)))
                {
                    Session[SessionHelper.PrivilegeForViewLoanCenter] = true;
                }
                else
                {
                    Session[SessionHelper.PrivilegeForViewLoanCenter] = false;
                }

                if (privileges.Any(p => p.Name.Trim().Equals(PrivilegeName.MailRoomQueue)) && !privileges.Any(p => p.Category == ( int )ActionCategory.ManagingQueues))
                {
                    Session[SessionHelper.CurrentTab] = LoanCenterTab.NewLoanApplication;
                }
                else if (privileges.Any(p => p.Name.Trim().Equals(PrivilegeName.DisplayAppraisalQueues)) && !privileges.Any(p => p.Category == ( int )ActionCategory.ManagingQueues))
                {
                    Session[SessionHelper.CurrentTab] = LoanCenterTab.OrderRequested;
                }
                else
                {
                    Session[SessionHelper.CurrentTab] = LoanCenterTab.Prospect;
                }
            }
            else
            {
                Session[SessionHelper.CurrentTab] = LoanCenterTab.Prospect;
            }

            Session[SessionHelper.LoanCenterVersion] = AccountHelper.HasPrivilege(MML.Common.PrivilegeName.ViewLoanCenter3) ? _version : 2;

            return(View());
        }