changePassword method

Future<void> changePassword({
  1. required String accessToken,
  2. required String previousPassword,
  3. required String proposedPassword,
})

Changes the password for a specified user in a user pool.

May throw ResourceNotFoundException. May throw InvalidParameterException. May throw InvalidPasswordException. May throw NotAuthorizedException. May throw TooManyRequestsException. May throw LimitExceededException. May throw PasswordResetRequiredException. May throw UserNotFoundException. May throw UserNotConfirmedException. May throw InternalErrorException.

Parameter accessToken : The access token.

Parameter previousPassword : The old password.

Parameter proposedPassword : The new password.

Implementation

Future<void> changePassword({
  required String accessToken,
  required String previousPassword,
  required String proposedPassword,
}) async {
  ArgumentError.checkNotNull(accessToken, 'accessToken');
  ArgumentError.checkNotNull(previousPassword, 'previousPassword');
  _s.validateStringLength(
    'previousPassword',
    previousPassword,
    6,
    256,
    isRequired: true,
  );
  ArgumentError.checkNotNull(proposedPassword, 'proposedPassword');
  _s.validateStringLength(
    'proposedPassword',
    proposedPassword,
    6,
    256,
    isRequired: true,
  );
  final headers = <String, String>{
    'Content-Type': 'application/x-amz-json-1.1',
    'X-Amz-Target': 'AWSCognitoIdentityProviderService.ChangePassword'
  };
  await _protocol.send(
    method: 'POST',
    requestUri: '/',
    exceptionFnMap: _exceptionFns,
    signed: false,
    // TODO queryParams
    headers: headers,
    payload: {
      'AccessToken': accessToken,
      'PreviousPassword': previousPassword,
      'ProposedPassword': proposedPassword,
    },
  );
}