in src/YouTrackSharp/Management/UserManagementService.cs [109:155]
public async Task UpdateUser(string username, string fullName = null, string email = null, string jabber = null, string password = null)
{
if (string.IsNullOrEmpty(username))
{
throw new ArgumentNullException(nameof(username));
}
var client = await _connection.GetAuthenticatedApiClient();
var users = await client.HubApiUsersGetAsync("login: {" + username + "}", "id,details(id,login)");
var user = users.Users.FirstOrDefault();
if (user == null)
{
throw new YouTrackErrorException(Strings.Exception_BadRequest, (int)HttpStatusCode.BadRequest,
"Could not find user with login " + username,
null, null);
}
if (!string.IsNullOrEmpty(fullName))
{
user.Name = fullName;
}
if (!string.IsNullOrEmpty(email))
{
user.Profile.Email = new HubApiEmail() {Email = email};
}
if (!string.IsNullOrEmpty(jabber))
{
user.Profile.Jabber = new HubApiJabber() {Jabber = jabber};
}
await client.HubUsersPostAsync(user.Id, "id", user);
if (!string.IsNullOrEmpty(password))
{
var detail = user.Details.SingleOrDefault(d => d is EmailuserdetailsJSON);
if (detail == null)
{
throw new YouTrackErrorException(Strings.Exception_BadRequest, (int)HttpStatusCode.BadRequest,
"Could not change password for user " + username + ": no single EmailUserDetails found",
null, null);
}
await client.HubUserdetailsPostAsync(detail.Id, "id",
new EmailuserdetailsJSON() {Password = new PlainpasswordJSON() {Value = password}});
}
}