コード例 #1
0
        public void SetCustomProfileShouldSetEmptyProperties([CoreDb] Db db, UserProfileProvider userProfileProvider, UserProfile userProfile, IDictionary <string, string> properties, string nullKey)
        {
            properties.Add(nullKey, null);

            userProfileProvider.SetCustomProfile(userProfile, properties);
            userProfile.Received()[nullKey] = string.Empty;
        }
コード例 #2
0
        private async Task ValidateUser(IOwinContext context)
        {
            string authHeader = context.Request.Headers["Authorization"];

            if (authHeader != null && authHeader.StartsWith("Basic"))
            {
                string encodedUsernamePassword = authHeader.Substring("Basic ".Length).Trim();
                var    encoding         = Encoding.GetEncoding("iso-8859-1");
                string usernamePassword = encoding.GetString(Convert.FromBase64String(encodedUsernamePassword));

                int seperatorIndex = usernamePassword.IndexOf(':');

                var username = usernamePassword.Substring(0, seperatorIndex);
                var password = usernamePassword.Substring(seperatorIndex + 1);
                if (!await _smsDao.IsAuthorizedUserAsync(username, password))
                {
                    throw new AuthorizationException($"User '{username}' is not authorized to access the api.");
                }
                UserProfileProvider.SetUserProfile(new UserProfile(username));
            }
            else
            {
                throw new AuthorizationException("The authorization header is either empty or is not Basic.");
            }
        }
コード例 #3
0
 public void SetCustomProfileShouldSetProperties([CoreDb] Db db, UserProfileProvider userProfileProvider, UserProfile userProfile, IDictionary <string, string> properties)
 {
     userProfileProvider.SetCustomProfile(userProfile, properties);
     foreach (var property in properties)
     {
         userProfile.Received()[property.Key] = property.Value;
     }
 }
コード例 #4
0
        public static UserProfileProvider GetUserProfileProvider()
        {
            if (userProfileProvider == null)
            {
                userProfileProvider = new UserProfileProvider();
            }

            return(userProfileProvider);
        }
コード例 #5
0
 public DefaultRegistry()
 {
     Scan(
         scan => {
         scan.TheCallingAssembly();
         scan.WithDefaultConventions();
         scan.AssembliesFromApplicationBaseDirectory(assembly => !assembly.FullName.StartsWith("System.Web"));
         scan.With(new ControllerConvention());
         scan.LookForRegistries();
     });
     For <IValidatorFactory>().Use <StructureMapValidatorFactory>();
     For <UserProfile>(Lifecycles.Container).Use(() => UserProfileProvider.GetUserProfile());
 }
コード例 #6
0
        public static IServiceCollection AddUserProviderFromMessage(this IServiceCollection builder, Message message)
        {
            builder.AddScoped <IUserProfileProvider, UserProfileProvider>((ctx) =>
            {
                Reference user = message.GetUserDetails();

                UserProfileProvider userProfileProvider = new UserProfileProvider();

                userProfileProvider.SetUser(user.Id, user.Name);

                return(userProfileProvider);
            });

            return(builder);
        }
コード例 #7
0
        public static IServiceCollection AddUserProviderFromRequest(this IServiceCollection builder)
        {
            builder.AddScoped <IUserProfileProvider, UserProfileProvider>((ctx) =>
            {
                IHttpContextAccessor httpContextAccessor = ctx.GetService <IHttpContextAccessor>();

                string userId = httpContextAccessor.HttpContext?.User?.Claims.FirstOrDefault(m => m.Type == ClaimTypes.Sid)?.Value;

                string userName = httpContextAccessor.HttpContext?.User?.Claims.FirstOrDefault(m => m.Type == ClaimTypes.Name)?.Value;

                UserProfileProvider userProfileProvider = new UserProfileProvider();

                userProfileProvider.SetUser(userId, userName);

                return(userProfileProvider);
            });

            return(builder);
        }
コード例 #8
0
 /// <summary>
 /// Construct the cmdlet.
 /// </summary>
 public DisconnectCohesityCluster()
 {
     userProfileProvider = ServiceLocator.GetUserProfileProvider();
 }
コード例 #9
0
ファイル: action.aspx.cs プロジェクト: uNormatov/FreboCms
        protected override void Init()
        {
            base.Init();

            if (_userProfileProvider == null)
                _userProfileProvider = new UserProfileProvider();
            if (_roleProfileProvider == null)
                _roleProfileProvider = new RoleProfileProvider();
            if (_generalConnection == null)
                _generalConnection = new GeneralConnection();
            if (_contentTypeProvider == null)
                _contentTypeProvider = new ContentTypeProvider();

            if (IsEdit)
            {
                Title = "Edit User | " + CoreSettings.CurrentSite.Name;
                ltlTitle.Text = "Edit";
            }
            else
            {
                Title = "New User | " + CoreSettings.CurrentSite.Name;
                ltlTitle.Text = "New";
            }

            if (IsEdit)
            {
                UserProfileInfo userProfileInfo = _userProfileProvider.SelectByUserId(Id, ErrorList);
                string[] selectedRoles = Roles.GetRolesForUser(Id);
                if (selectedRoles.Length > 0)
                {
                    RoleProfileInfo roleProfileInfo = _roleProfileProvider.SelectByRoleId(selectedRoles[0], ErrorList);
                    if (userProfileInfo != null && roleProfileInfo != null)
                    {
                        ContentTypeId = roleProfileInfo.ContentTypeId;
                        ContentId = userProfileInfo.ContentId;
                        pnlContentType.Visible = true;
                        ShowContentType();
                    }
                }
            }
        }
コード例 #10
0
 public void SetCustomProfileShouldSaveProfile([CoreDb] Db db, UserProfileProvider userProfileProvider, UserProfile userProfile, IDictionary <string, string> properties)
 {
     userProfileProvider.SetCustomProfile(userProfile, properties);
     userProfile.Received().Save();
 }
コード例 #11
0
 public void GetCustomPropertiesShouldReturnEmptyProperties([CoreDb] Db db, [Content] ProfileTemplate template, DbItem profileItem, UserProfileProvider userProfileProvider, UserProfile userProfile)
 {
     userProfileProvider.GetCustomProperties(userProfile).Should().BeEmpty();
 }
コード例 #12
0
 public void GetCustomPropertiesShouldReturnProperties([CoreDb] Db db, [Content] ProfileTemplate template, [Content] DbItem profileItem, UserProfileProvider userProfileProvider, UserProfile userProfile)
 {
     userProfileProvider.GetCustomProperties(userProfile).Should().ContainKeys("FirstName", "LastName", "Phone");
 }