public async Task <IActionResult> CreateFirstUser(CreateFirstIUserInputModel model) { if (await _userManager.Users.AnyAsync() == true) { return(RedirectToAction("Login", new { returnUrl = model.ReturnUrl })); } if (ModelState.IsValid == false) { return(View(model)); } else { foreach (var validator in _userManager.PasswordValidators) { var result = await validator.ValidateAsync(_userManager, null, model.Password); if (result.Succeeded == false) { ModelState.AddModelError(nameof(CreateFirstIUserInputModel.Password), _localizer["not complex enough"]); return(View(model)); } } } await _localUserService.CreateUser(model.Username, model.Password, model.DisplayName, model.ProfilePictureUrl); return(RedirectToAction("Login", new { returnUrl = model.ReturnUrl })); }
public async Task <String> Handle(CreateLocalUserCommand request, CancellationToken cancellationToken) { _logger.LogDebug("Handle started"); var possiblePictures = _profilePictureService.GetPossibleProfilePicture().Select(x => x.Url).ToHashSet(); if (possiblePictures.Contains(request.ProfilePictureUrl) == false) { return(String.Empty); } Guid?id = await _userService.CreateUser(request.Username, request.Password, request.DisplayName, request.ProfilePictureUrl); if (id.HasValue == false) { return(null); } return(id.ToString()); }