Esempio n. 1
0
        private void ContentFrame_Navigating(object sender, NavigatingCancelEventArgs e)
        {
            if (_secureViews.ContainsKey(e.Uri.OriginalString))
            {
                var requiredRole = _secureViews[e.Uri.OriginalString];

                if (e.NavigationMode != NavigationMode.Back && !WebContext.Current.User.IsAuthenticated)
                {
                    ErrorWindow.CreateNew(ApplicationStrings.Main_LoginRequired, StackTracePolicy.Never);
                    e.Cancel = true;
                }
                else if (e.NavigationMode != NavigationMode.Back &&
                         WebContext.Current.User.IsAuthenticated &&
                         !WebContext.Current.User.IsInRole(requiredRole))
                {
                    ErrorWindow.CreateNew(ApplicationStrings.Main_RoleRequired + requiredRole, StackTracePolicy.Never);
                    e.Cancel = true;
                }
            }
        }