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; }
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."); } }
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; } }
public static UserProfileProvider GetUserProfileProvider() { if (userProfileProvider == null) { userProfileProvider = new UserProfileProvider(); } return(userProfileProvider); }
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()); }
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); }
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); }
/// <summary> /// Construct the cmdlet. /// </summary> public DisconnectCohesityCluster() { userProfileProvider = ServiceLocator.GetUserProfileProvider(); }
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(); } } } }
public void SetCustomProfileShouldSaveProfile([CoreDb] Db db, UserProfileProvider userProfileProvider, UserProfile userProfile, IDictionary <string, string> properties) { userProfileProvider.SetCustomProfile(userProfile, properties); userProfile.Received().Save(); }
public void GetCustomPropertiesShouldReturnEmptyProperties([CoreDb] Db db, [Content] ProfileTemplate template, DbItem profileItem, UserProfileProvider userProfileProvider, UserProfile userProfile) { userProfileProvider.GetCustomProperties(userProfile).Should().BeEmpty(); }
public void GetCustomPropertiesShouldReturnProperties([CoreDb] Db db, [Content] ProfileTemplate template, [Content] DbItem profileItem, UserProfileProvider userProfileProvider, UserProfile userProfile) { userProfileProvider.GetCustomProperties(userProfile).Should().ContainKeys("FirstName", "LastName", "Phone"); }