private async Task UpdateUserPasswordAsync(string userId, string userName, string oldPassword, string newPassword) { Arguments.CheckNotNull(userId, nameof(userId)); Arguments.CheckNotNull(userName, nameof(userName)); Arguments.CheckNotNull(oldPassword, nameof(oldPassword)); Arguments.CheckNotNull(newPassword, nameof(newPassword)); var header = InfluxDBClient.AuthorizationHeader(userName, oldPassword); await _service.PutUsersIDPasswordAsync(userId, new PasswordResetBody(newPassword), null, header); }
/// <summary> /// Update the password to a currently authenticated user. /// </summary> /// <param name="oldPassword">old password</param> /// <param name="newPassword">new password</param> /// <returns>currently authenticated user</returns> public async Task MeUpdatePasswordAsync(string oldPassword, string newPassword) { Arguments.CheckNotNull(oldPassword, nameof(oldPassword)); Arguments.CheckNotNull(newPassword, nameof(newPassword)); var me = await MeAsync().ConfigureAwait(false); if (me == null) { Trace.WriteLine("User is not authenticated."); return; } var header = InfluxDBClient.AuthorizationHeader(me.Name, oldPassword); await _service.PutMePasswordAsync(new PasswordResetBody(newPassword), null, header).ConfigureAwait(false); }
/// <summary> /// Update the password to a currently authenticated user. /// </summary> /// <param name="oldPassword">old password</param> /// <param name="newPassword">new password</param> /// <returns>currently authenticated user</returns> public async Task MeUpdatePasswordAsync(string oldPassword, string newPassword) { Arguments.CheckNotNull(oldPassword, nameof(oldPassword)); Arguments.CheckNotNull(newPassword, nameof(newPassword)); await MeAsync().ContinueWith(async t => { if (t.Result == null) { Trace.WriteLine("User is not authenticated."); return; } var header = InfluxDBClient.AuthorizationHeader(t.Result.Name, oldPassword); await _service.PutMePasswordAsync(new PasswordResetBody(newPassword), null, header); }).Unwrap(); }