Example #1
0
        public virtual async Task HandleUserInfoGet(
            ISiteContext site,
            SiteUser siteUser,
            UserInfoViewModel viewModel,
            HttpContext httpContext,
            ViewDataDictionary viewData,
            CancellationToken cancellationToken = default(CancellationToken)
            )
        {
            await EnsureProps();

            // add user props to viewData to pass them to the view
            var userProps = await _userPropertyService.FetchByUser(site.Id.ToString(), siteUser.Id.ToString());

            foreach (var p in _props.Properties)
            {
                if (p.VisibleToUserOnProfile)
                {
                    if (_userPropertyService.IsNativeUserProperty(p.Key))
                    {
                        viewData[p.Key] = _userPropertyService.GetNativeUserProperty(siteUser, p.Key);
                    }
                    else
                    {
                        var found = userProps.Where(x => x.Key == p.Key).FirstOrDefault();
                        if (found != null)
                        {
                            viewData[p.Key] = found.Value;
                        }
                    }
                }
            }
        }
        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));
        }