/// <summary> /// Posts the specified request. /// </summary> /// <param name="request">The request.</param> /// <returns>System.Object.</returns> public async Task <object> Post(CreateUserByName request) { var dtoUser = request; var newUser = await _userManager.CreateUser(dtoUser.Name).ConfigureAwait(false); var result = _userManager.GetUserDto(newUser, Request.RemoteIp); return(ToOptimizedResult(result)); }
/// <summary> /// Posts the specified request. /// </summary> /// <param name="request">The request.</param> /// <returns>System.Object.</returns> public object Post(CreateUserByName request) { var dtoUser = request; var newUser = _userManager.CreateUser(dtoUser.Name).Result; var result = _userManager.GetUserDto(newUser, Request.RemoteIp); return(ToOptimizedResult(result)); }
/// <summary> /// Posts the specified request. /// </summary> /// <param name="request">The request.</param> /// <returns>System.Object.</returns> public async Task <object> Post(CreateUserByName request) { var newUser = _userManager.CreateUser(request.Name); // no need to authenticate password for new user if (request.Password != null) { await _userManager.ChangePassword(newUser, request.Password).ConfigureAwait(false); } var result = _userManager.GetUserDto(newUser, Request.RemoteIp); return(ToOptimizedResult(result)); }
/// <summary> /// Posts the specified request. /// </summary> /// <param name="request">The request.</param> /// <returns>System.Object.</returns> public async Task <object> Post(CreateUserByName request) { var dtoUser = request; var users = _userManager.Users; var session = _authRepo.Get(new AuthenticationInfoQuery { AccessToken = request.AccessToken }).Items.FirstOrDefault(); if (session == null) { throw new ArgumentException("Invalid access token."); } var account = _userManager.Accounts.FirstOrDefault(i => i.Guid == session.UserId); if (account == null) { throw new ArgumentException("Invalid account."); } var profiles = users.Where(i => i.AccountId == account.Id).ToList(); if (profiles.Count < 5) { var newUser = await _userManager.CreateUser(String.Format("[{0}]{1}", account.Guid.ToString("N"), dtoUser.Name), account).ConfigureAwait(false); var result = _userManager.GetUserDto(newUser, Request.RemoteIp); return(ToOptimizedResult(result)); } throw new ArgumentException("The maximum number of profiles has been reached."); }