ArcGISPortalViewer.ViewModel.SignInViewModel.GetAnonymousAccessStatusAsync C# (CSharp) Method

GetAnonymousAccessStatusAsync() public method

public GetAnonymousAccessStatusAsync ( ) : Task
return Task
        public async Task<bool> GetAnonymousAccessStatusAsync()
        {
            bool b = false;

            if (PortalService.CurrentPortalService.Portal != null)
                b = PortalService.CurrentPortalService.Portal.ArcGISPortalInfo.Access == PortalAccess.Public;
            else
            {
                var challengeHandler = IdentityManager.Current.ChallengeHandler;
                // Deactivate the challenge handler temporarily before creating the portal (else challengehandler would be called for portal secured by native)
                IdentityManager.Current.ChallengeHandler = new ChallengeHandler(crd => null);

                ArcGISPortal p = null;
                try
                {
                    p = await ArcGISPortal.CreateAsync(App.PortalUri.Uri);
                }
                catch
                {
                }

                if (p != null && p.ArcGISPortalInfo != null)
                {
                    b = p.ArcGISPortalInfo.Access == PortalAccess.Public;
                }

                // Restore ChallengeHandler
                IdentityManager.Current.ChallengeHandler = challengeHandler;
            }

            return b;
        }