public IActionResult Put([BindRequired, FromBody] AltSourceNewUserDto input) { try { UserInputValidation.ValidateUsername(input.Username); UserInputValidation.ValidatePassword(input.Password); UserInputValidation.ValidateName(input.FirstName); UserInputValidation.ValidateName(input.LastName); UserInputValidation.ValidateAddress(input.Address); var encodedAddress = HtmlEncoder.Default.Encode(input.Address); // ReSharper disable once UnusedVariable var result = Users.CreateAltSourceUser(_userManager, input.Username, input.Password, input.FirstName, input.LastName, encodedAddress, false) .Result; if (!result.Succeeded) { return(BadRequest(result.CompileErrorMessage())); } } catch (Exception ex) { return(BadRequest(ex.Message)); } return(Ok()); }
public ActionResult <string> CreateClient([Required, FromBody] AltSourceNewClientDto input) { AccountsLib.Client newClient; try { UserInputValidation.ValidateUsername(input.Username); UserInputValidation.ValidateName(input.FirstName); UserInputValidation.ValidateName(input.LastName); var userInfo = User.GetUserInfo(); var username = userInfo.AccountsUsername; using (var session = Logic.Login(Repository, username)) { newClient = Logic.CreateClient(session, input.Username, input.FirstName, input.LastName); } } catch (AccountsLibException ex) { return(new ActionFailureResult(new ApiResponse(500, ex.Message))); } return(newClient?.ClientId); }
/// <summary> /// Creates a new user in the Accounts database. The new user must be linked to a corresponding /// Identity on the Identity Server by setting the <see cref="ApplicationClaimTypes.ACCOUNTS_USERNAME"/> /// claim for that Identity /// to <c>username</c> /// </summary> /// <param name="username"> /// The username to be assigned to the new User. Must match the value of the /// <see cref="ApplicationClaimTypes.ACCOUNTS_USERNAME"/> claim type on the corresponding Identity /// on the Identity Server. /// </param> /// <returns>void</returns> public async Task <bool> CreateUser(string username) { UserInputValidation.ValidateUsername(username); var response = await this.InvokeApiAsync(Post, $"api/admin/create/user/{username}"); return(response.IsSuccessStatusCode); }
public ActionResult <bool> CreateUser([Required, FromRoute] string newUsername) { UserInputValidation.ValidateUsername(newUsername); var userInfo = User.GetUserInfo(); var username = userInfo.AccountsUsername; using (var session = Logic.Login(Repository, username)) { // ReSharper disable once UnusedVariable var newUser = Logic.CreateUser(session, newUsername); } return(true); }
public async Task <string> CreateClient(string username, string firstName, string lastName) { UserInputValidation.ValidateUsername(username); UserInputValidation.ValidateName(firstName); UserInputValidation.ValidateName(lastName); var newClient = new AltSourceNewClientDto(username, firstName, lastName); var jsonNewUser = JsonConvert.SerializeObject(newClient); var content = new StringContent(jsonNewUser, Encoding.UTF8, "application/json"); var response = await this.InvokeApiAsync(Post, @"api/admin/create/client", content); var newClientId = await response.TryGetResponseContent(); return(newClientId); }