private void HandleRequestAuthenticationCompleted(object userState) { if (!AuthorizationNavigationManager.IsAuthorized(this.GetCurrentUri(), this._frame.Content)) { // If the user is still not authorized, he needs to be redirected this.Redirect(); } }
private static void ContentLoaderPropertyChanged(object sender, DependencyPropertyChangedEventArgs e) { AuthorizationNavigationManager manager = (AuthorizationNavigationManager)sender; if (!(e.NewValue is AuthorizationContentLoader)) { manager._frame.ContentLoader = new AuthorizationContentLoader( manager._frame, (INavigationContentLoader)e.NewValue ?? new PageResourceContentLoader()); } manager.SetDefaultSource(manager._frame.Source); }
private void AuthorizeFrameContent() { if (!AuthorizationNavigationManager.IsAuthorized(this.GetCurrentUri(), this._frame.Content)) { AuthorizationNavigationMode navigationMode = this.GetContentNavigationMode(this._frame.Content); if (WebContextBase.Current.Authentication.User.Identity.IsAuthenticated || (navigationMode == AuthorizationNavigationMode.Redirect)) { // If the user is authenticated but not authorized, he needs to be redirected this.Redirect(); } else if (navigationMode == AuthorizationNavigationMode.Prompt) { if (Authorization.Prompter == null) { throw new InvalidOperationException("Authorization.Prompter cannot be null when the navigationMode is 'Prompt'."); } // If the user is not authenticated, we need to prompt for re-authentication or redirect Authorization.Prompter.RequestAuthentication(this.HandleRequestAuthenticationCompleted, null); } } }
private static void SetNavigationManager(DependencyObject target, AuthorizationNavigationManager value) { target.SetValue(Authorization.NavigationManagerProperty, value); }
private static void SourcePropertyChanged(object sender, DependencyPropertyChangedEventArgs e) { AuthorizationNavigationManager manager = (AuthorizationNavigationManager)sender; manager.SetDefaultSource((Uri)e.NewValue); }