예제 #1
0
 private void SetupSecurity()
 {
     // Check if we can edit extended properties
     if ((_userProvider is INSurveyUserProvider))
     {
         CheckRight(NSurveyRights.AccessUserManager, true);
     }
     else
     {
         UINavigator.NavigateToAccessDenied(SurveyId, MenuIndex);
     }
 }
        /// <summary>
        /// IsSingleUserMode boolean
        /// </summary>
        /// <remarks>Check if the system was setup in single user mode</remarks>
        /// <param name="redirectIfSingle"></param>
        /// <returns>true or false</returns>

        public bool IsSingleUserMode(bool redirectIfSingle)
        {
            // Did the system setup a dummy admin
            if (NSurveyUser.Identity.UserId == 0 &&
                NSurveyUser.Identity.IsAdmin)
            {
                if (redirectIfSingle)
                {
                    UINavigator.NavigateToAccessDenied(SurveyId, MenuIndex);
                }
                return(true);
            }
            return(false);
        }
        /// <summary>
        /// Check if the current user has the given right
        /// else if specified redirect to the access denied page
        /// </summary>
        /// <param name="right"></param>
        /// <param name="accessDeniedRedirect"></param>
        /// <returns>true or false</returns>
        public bool CheckRight(NSurveyRights right, bool accessDeniedRedirect)
        {
            if (NSurveyUser.Identity.IsAdmin ||
                NSurveyUser.HasRight(right))
            {
                return(true);
            }
            else if (accessDeniedRedirect)
            {
                UINavigator.NavigateToAccessDenied(getSurveyId(), MenuIndex);
            }

            return(false);
        }