public Task ProcessUserBeforeCreate(ISiteUser siteUser, HttpContext httpContext) { if (siteUser != null) { foreach (var p in _props.Properties) { if (p.EditableOnAdminUserEdit) { if (_userPropertyService.IsNativeUserProperty(p.Key)) { var postedValue = httpContext.Request.Form[p.Key]; _userPropertyService.UpdateNativeUserProperty(siteUser, p.Key, postedValue); } } } // we don't need to save the user here it is saved after this method } return(Task.FromResult(0)); }
public virtual async Task HandleUserEditPostSuccess( ISiteContext site, ISiteUser siteUser, EditUserViewModel viewModel, HttpContext httpContext, CancellationToken cancellationToken = default(CancellationToken) ) { await EnsureProps(); // we "could" re-validate here but // the method above gets called just before this in the same postback // so we know there were no validation errors or this method would not be invoked if (siteUser != null) { foreach (var p in _props.Properties) { if (p.EditableOnAdminUserEdit) { var postedValue = httpContext.Request.Form[p.Key]; if (_userPropertyService.IsNativeUserProperty(p.Key)) { _userPropertyService.UpdateNativeUserProperty(siteUser, p.Key, postedValue); } else { // persist to kvp storage await _userPropertyService.CreateOrUpdate( site.Id.ToString(), siteUser.Id.ToString(), p.Key, postedValue); } } } } else { _log.LogError("user was null in HandleUserInfoPostSuccess, unable to update user with custom data"); } }