public virtual ActionResult Home()
        {
            var identity           = OwinContext.Authentication?.User?.Identity as ClaimsIdentity;
            var showTransformModal = ClaimsExtensions.HasDiscontinuedLoginCLaims(identity);

            return(View(new GalleryHomeViewModel(showTransformModal)));
        }
        public virtual ActionResult Home()
        {
            var identity                  = OwinContext.Authentication?.User?.Identity as ClaimsIdentity;
            var showTransformModal        = ClaimsExtensions.HasDiscontinuedLoginClaims(identity);
            var transformIntoOrganization = _contentObjectService.LoginDiscontinuationConfiguration
                                            .ShouldUserTransformIntoOrganization(GetCurrentUser());

            return(View(new GalleryHomeViewModel(showTransformModal, transformIntoOrganization)));
        }
        private static bool HasBooleanClaim(IPrincipal self, string claimType)
        {
            if (self == null || self.Identity == null)
            {
                return(false);
            }

            var identity = self.Identity as ClaimsIdentity;

            return(ClaimsExtensions.HasBooleanClaim(identity, claimType));
        }
        /// <summary>
        /// Determine if the current user logged in with azure active directory account
        /// </summary>
        /// <param name="self">Current user principal.</param>
        public static bool WasAzureActiveDirectoryAccountUsedForSignin(this IPrincipal self)
        {
            if (self == null || self.Identity == null)
            {
                return(false);
            }

            var identity = self.Identity as ClaimsIdentity;

            return(ClaimsExtensions.LoggedInWithAzureActiveDirectory(identity));
        }
        /// <summary>
        /// Determine if the current user logged in with personal microsoft account
        /// </summary>
        /// <param name="self">Current user principal.</param>
        public static bool WasMicrosoftAccountUsedForSignin(this IPrincipal self)
        {
            if (self == null || self.Identity == null)
            {
                return(false);
            }

            var identity = self.Identity as ClaimsIdentity;

            return(ClaimsExtensions.LoggedInWithMicrosoftAccount(identity));
        }
        /// <summary>
        /// Determine if the current user has an associated password credential.
        /// </summary>
        /// <param name="self">Current user principal.</param>
        /// <returns>True if user has password credential, false otherwise.</returns>
        public static bool HasPasswordLogin(this IPrincipal self)
        {
            if (self == null || self.Identity == null)
            {
                return(false);
            }

            var identity = self.Identity as ClaimsIdentity;

            return(ClaimsExtensions.HasBooleanClaim(identity, NuGetClaims.PasswordLogin));
        }
Exemple #7
0
        /// <summary>
        /// Try to add a new default claim to the identity. It will not replace an existing claim.
        /// </summary>
        /// <param name="identity">IIdentity from which the claim is to be removed</param>
        /// <param name="claimType">The claim type to be added</param>
        /// <returns>True if successfully able to add the claim, false otherwise</returns>
        public static bool TryAddClaim(this IIdentity identity, string claimType)
        {
            var claimsIdentity = identity as ClaimsIdentity;
            var existingClaim  = claimsIdentity?.FindFirst(claimType);

            if (existingClaim == null)
            {
                claimsIdentity.AddClaim(ClaimsExtensions.CreateBooleanClaim(claimType));
                return(true);
            }

            return(false);
        }
Exemple #8
0
        public virtual ActionResult Home()
        {
            var identity           = OwinContext.Authentication?.User?.Identity as ClaimsIdentity;
            var showTransformModal = ClaimsExtensions.HasDiscontinuedLoginClaims(identity);
            var user = GetCurrentUser();
            var transformIntoOrganization = _contentObjectService
                                            .LoginDiscontinuationConfiguration
                                            .ShouldUserTransformIntoOrganization(user);
            var externalIdentityList      = ClaimsExtensions.GetExternalCredentialIdentityList(identity);
            var showEnable2FAModal        = _featureFlagService.IsShowEnable2FADialogEnabled();
            var getFeedbackOnModalDismiss = _featureFlagService.IsGet2FADismissFeedbackEnabled();

            return(View(new GalleryHomeViewModel(showTransformModal, transformIntoOrganization, showEnable2FAModal, getFeedbackOnModalDismiss, externalIdentityList)));
        }
        /// <summary>
        /// Try to add a new default claim to the identity. It will not replace an existing claim.
        /// </summary>
        /// <param name="identity">IIdentity from which the claim is to be removed</param>
        /// <param name="claimType">The claim type to be added</param>
        /// <param name="claimValue">The claim value for the type to be added, null will add default boolean claim</param>
        /// <returns>True if successfully able to add the claim, false otherwise</returns>
        public static bool TryAddClaim(this IIdentity identity, string claimType, string claimValue = null)
        {
            var claimsIdentity = identity as ClaimsIdentity;
            var existingClaim  = claimsIdentity?.FindFirst(claimType);

            if (existingClaim == null)
            {
                var claim = string.IsNullOrEmpty(claimValue)
                    ? ClaimsExtensions.CreateBooleanClaim(claimType)
                    : new Claim(claimType, claimValue);

                claimsIdentity.AddClaim(claim);
                return(true);
            }

            return(false);
        }