コード例 #1
0
        /// <summary>
        /// Make a NeptuneMenuItem from a route. A feature is required on the Route and will be used to check access for the menu item.
        /// If menu item is not accessible, it will not be shown.
        /// </summary>
        public static LtInfoMenuItem MakeItem <T>(SitkaRoute <T> route, Person currentPerson, string menuItemName, string menuGroupName) where T : Controller
        {
            var urlString  = route.BuildUrlFromExpression();
            var shouldShow = NeptuneBaseFeature.IsAllowed(route, currentPerson);

            return(new LtInfoMenuItem(urlString, menuItemName, shouldShow, false, menuGroupName));
        }
コード例 #2
0
ファイル: WebServiceToken.cs プロジェクト: sitkatech/neptune
        /// <summary>
        /// Throws an exception if the <see cref="Person"/> associated with this <see cref="WebServiceToken"/> does not have access to <see cref="LakeTahoeInfoBaseFeature" />
        /// In a unit test using <see cref="WebServiceTokenGuidForUnitTests"/> this will always pass, and <see cref="Person"/> will return Ray Lee's person ID for now
        /// Might want to introduce a system person at some point.
        /// </summary>
        /// <param name="feature"></param>
        public void DemandHasPermission(NeptuneBaseFeature feature)
        {
            if (IsValidAsUnitTestToken(_tokenGuid, false))
            {
                // We consider the Unit Test one good if it's in the right environment
                return;
            }
            Check.RequireNotNull(_person,
                                 $"The provided token {WebServiceTokenModelBinder.WebServiceTokenParameterName} = \"{_tokenGuid}\" is not associated with a person. Cannot check for access to feature \"{feature.FeatureName}\"");
            var hasPermission = feature.HasPermissionByPerson(_person);

            Check.Require(hasPermission,
                          $"Web service token \"{_tokenGuid}\" is for person \"{_person.GetFullNameFirstLast()}\" PersonID={_person.PersonID}, but that person does not have access to feature \"{feature.FeatureName}\"");
        }