public UserProfileId GetUniqueID(GetUniqueId uniqueIdInfo)
        {
            var profileId = new UserProfileId();

            profileId.UniqueId = dal.GetUniqueID(uniqueIdInfo.UserName, uniqueIdInfo.IsAuthenticated, uniqueIdInfo.IgnoreAuthenticationType, uniqueIdInfo.AppName);
            return(profileId);
        }
Beispiel #2
0
        // Reverse navigation
        //public virtual ICollection<UserPasswordHistory> UserPasswordHistories { get; set; }
        //public virtual ICollection<UserQuestionAnswer> UserQuestionAnswers { get; set; }

        public async Task <ClaimsIdentity> GenerateUserIdentityAsync(UserManager <UserProfile> manager)
        {
            // Note the authenticationType must match the one defined in CookieAuthenticationOptions.AuthenticationType
            var userIdentity = await manager.CreateIdentityAsync(user : this, authenticationType : DefaultAuthenticationTypes.ApplicationCookie);

            // Add custom user claims here
            userIdentity.AddClaim(claim: new Claim(type: "UserFullName", value: FirstName + " " + LastName));
            userIdentity.AddClaim(claim: new Claim(type: "UserProfileId", value: UserProfileId.ToString()));
            userIdentity.AddClaim(claim: new Claim(type: "UserName", value: UserName));
            userIdentity.AddClaim(claim: new Claim(type: "Email", value: Email));

            return(userIdentity);
        }
Beispiel #3
0
        public void UserIsNotAuthenticatedInWhenSessionProfileLoginIsNull()
        {
            var loggerMock     = new Mock <IInternalLogger>();
            var webContextMock = new Mock <IWebContext>();

            webContextMock.Setup(x => x.IsExist()).Returns(true);

            var userLogin = new UserProfileId(webContextMock.Object, loggerMock.Object);
            int id;
            var authenticated = userLogin.IsAuthenticated(out id);

            Assert.That(authenticated, Is.False);
            Assert.That(id, Is.EqualTo(-1));
        }
Beispiel #4
0
        public static bool IsFeatureToggleEnabled(Features feature)
        {
            var            securityConfiguration = new SecurityConfiguration();
            var            internalLogger        = new InternalLogger(securityConfiguration);
            var            webContext            = new WebContext();
            IUserProfileId userProfileId         = new UserProfileId(webContext, internalLogger);

            var jwt = new JwtTokenRequestClient(securityConfiguration, internalLogger, userProfileId, new JwtTokenCache(webContext));

            var securityTokenServiceProxy = new SecurityTokenServiceProxy(jwt, securityConfiguration);
            var httpClientProxy           = new HttpClientProxy(securityTokenServiceProxy);
            var configuration             = new Configuration();
            var restClient    = new RestClient(configuration, httpClientProxy);
            var featureToggle = new FeatureToggle(restClient);

            return(featureToggle.IsEnabled(feature));
        }