Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: rename sendUserAttributeVerificationCode #3759

Merged
merged 3 commits into from
Oct 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions packages/amplify_core/doc/lib/auth.dart
Original file line number Diff line number Diff line change
Expand Up @@ -437,18 +437,18 @@ Future<void> verifyAttributeUpdate() async {
}
// #enddocregion confirm-user-attribute

// #docregion resend-user-attribute-code
// #docregion send-user-attribute-verification-code
Future<void> resendVerificationCode() async {
try {
final result = await Amplify.Auth.resendUserAttributeConfirmationCode(
final result = await Amplify.Auth.sendUserAttributeVerificationCode(
userAttributeKey: AuthUserAttributeKey.email,
);
_handleCodeDelivery(result.codeDeliveryDetails);
} on AuthException catch (e) {
safePrint('Error resending code: ${e.message}');
}
}
// #enddocregion resend-user-attribute-code
// #enddocregion send-user-attribute-verification-code

// #docregion remember-device
Future<void> rememberCurrentDevice() async {
Expand Down
38 changes: 25 additions & 13 deletions packages/amplify_core/lib/src/category/amplify_auth_category.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1233,19 +1233,16 @@ class AuthCategory extends AmplifyCategory<AuthPluginInterface> {
),
);

/// {@template amplify_core.amplify_auth_category.resend_user_attribute_confirmation_code}
/// Resends a confirmation code for the given [userAttributeKey], if required, while
/// updating the attribute.
/// {@template amplify_core.amplify_auth_category.send_attribute_verification_code}
/// Sends a confirmation code for the existing value for the given
/// [userAttributeKey].
///
/// If a confirmation code sent as the result of a [updateUserAttribute] or [updateUserAttributes]
/// call expires, you can use this API to request a new one.
/// This API can be used to confirm an attribute that was not confirmed during
/// the sign up flow.
///
/// Optionally accepts plugin [options] which allow customizing provider-specific
/// behavior, e.g. the Cognito User Pool.
///
/// For more information, see the
/// [Amplify docs](https://docs.amplify.aws/lib/auth/user-attributes/q/platform/flutter/#resend-verification-code).
///
/// ## Examples
///
/// <?code-excerpt "doc/lib/auth.dart" region="imports"?>
Expand All @@ -1254,11 +1251,11 @@ class AuthCategory extends AmplifyCategory<AuthPluginInterface> {
/// import 'package:amplify_flutter/amplify_flutter.dart';
/// ```
///
/// <?code-excerpt "doc/lib/auth.dart" region="resend-user-attribute-code"?>
/// <?code-excerpt "doc/lib/auth.dart" region="send-user-attribute-verification-code"?>
/// ```dart
/// Future<void> resendVerificationCode() async {
/// try {
/// final result = await Amplify.Auth.resendUserAttributeConfirmationCode(
/// final result = await Amplify.Auth.sendUserAttributeVerificationCode(
/// userAttributeKey: AuthUserAttributeKey.email,
/// );
/// _handleCodeDelivery(result.codeDeliveryDetails);
Expand All @@ -1269,7 +1266,7 @@ class AuthCategory extends AmplifyCategory<AuthPluginInterface> {
/// ```
///
/// The details of where the code will be delivered are returned in the result's
/// [ResendUserAttributeConfirmationCodeResult.codeDeliveryDetails] property
/// [SendUserAttributeVerificationCodeResult.codeDeliveryDetails] property
/// and should be used to prompt the user on where to look for the code.
///
/// <?code-excerpt "doc/lib/auth.dart" region="handle-code"?>
Expand All @@ -1282,14 +1279,29 @@ class AuthCategory extends AmplifyCategory<AuthPluginInterface> {
/// }
/// ```
/// {@endtemplate}
Future<SendUserAttributeVerificationCodeResult>
sendUserAttributeVerificationCode({
required AuthUserAttributeKey userAttributeKey,
SendUserAttributeVerificationCodeOptions? options,
}) =>
identifyCall(
AuthCategoryMethod.sendUserAttributeVerificationCode,
() => defaultPlugin.sendUserAttributeVerificationCode(
userAttributeKey: userAttributeKey,
options: options,
),
);

/// {@macro amplify_core.amplify_auth_category.send_attribute_verification_code}
@Deprecated('Use sendUserAttributeVerificationCode.')
Jordan-Nelson marked this conversation as resolved.
Show resolved Hide resolved
Future<ResendUserAttributeConfirmationCodeResult>
resendUserAttributeConfirmationCode({
required AuthUserAttributeKey userAttributeKey,
ResendUserAttributeConfirmationCodeOptions? options,
}) =>
identifyCall(
AuthCategoryMethod.resendUserAttributeConfirmationCode,
() => defaultPlugin.resendUserAttributeConfirmationCode(
AuthCategoryMethod.sendUserAttributeVerificationCode,
() => defaultPlugin.sendUserAttributeVerificationCode(
userAttributeKey: userAttributeKey,
options: options,
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ enum AuthCategoryMethod with AmplifyCategoryMethod {
getCurrentUser('10'),
rememberDevice('11'),
resendSignUpCode('12'),
resendUserAttributeConfirmationCode('13'),
sendUserAttributeVerificationCode('13'),
resetPassword('14'),
signIn('15'),
signInWithWebUI('16'),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,8 @@ abstract class AuthPluginInterface extends AmplifyPluginInterface {
);
}

/// {@macro amplify_core.amplify_auth_category.resend_user_attribute_confirmation_code}
/// {@macro amplify_core.amplify_auth_category.send_attribute_verification_code}
@Deprecated('Use sendUserAttributeVerificationCode instead.')
Jordan-Nelson marked this conversation as resolved.
Show resolved Hide resolved
Future<ResendUserAttributeConfirmationCodeResult>
resendUserAttributeConfirmationCode({
required AuthUserAttributeKey userAttributeKey,
Expand All @@ -164,6 +165,17 @@ abstract class AuthPluginInterface extends AmplifyPluginInterface {
);
}

/// {@macro amplify_core.amplify_auth_category.send_attribute_verification_code}
Future<SendUserAttributeVerificationCodeResult>
sendUserAttributeVerificationCode({
required AuthUserAttributeKey userAttributeKey,
SendUserAttributeVerificationCodeOptions? options,
}) {
throw UnimplementedError(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To keep this non-breaking can we have the default impl call resend?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How would this change be breaking? Maybe I am missing something.

'sendUserAttributeVerificationCode() has not been implemented.',
);
}

/// {@macro amplify_core.amplify_auth_category.set_up_totp}
Future<TotpSetupDetails> setUpTotp({
TotpSetupOptions? options,
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0

import 'package:amplify_core/amplify_core.dart';

/// {@category Auth}
/// {@template amplify_core.send_attribute_verification_code_options}
/// The shared send user attribute verification code options among all Auth
/// plugins.
/// {@endtemplate}
class SendUserAttributeVerificationCodeOptions
with
AWSEquatable<SendUserAttributeVerificationCodeOptions>,
AWSSerializable<Map<String, Object?>>,
AWSDebuggable {
/// {@macro amplify_core.send_attribute_verification_code_options}
const SendUserAttributeVerificationCodeOptions({
this.pluginOptions,
});

/// {@macro amplify_core.auth.send_user_attribute_verification_code_plugin_options}
final SendUserAttributeVerificationCodePluginOptions? pluginOptions;

@override
List<Object?> get props => [pluginOptions];

@override
String get runtimeTypeName => 'SendUserAttributeVerificationCodeOptions';

/// @nodoc
@Deprecated('Use toJson instead')
Map<String, Object?> serializeAsMap() => toJson();

@override
Map<String, Object?> toJson() => {
'pluginOptions': pluginOptions?.toJson(),
};
}

/// @nodoc
/// {@template amplify_core.auth.send_user_attribute_verification_code_plugin_options}
/// Plugin-specific options for `Amplify.Auth.sendUserAttributeVerificationCode`.
/// {@endtemplate}
abstract class SendUserAttributeVerificationCodePluginOptions
with
AWSEquatable<SendUserAttributeVerificationCodePluginOptions>,
AWSSerializable<Map<String, Object?>>,
AWSDebuggable {
/// {@macro amplify_core.auth.send_user_attribute_verification_code_plugin_options}
const SendUserAttributeVerificationCodePluginOptions();
}

/// {@macro amplify_core.send_attribute_verification_code_options}
@Deprecated('Use SendUserAttributeVerificationCodeOptions.')
typedef ResendUserAttributeConfirmationCodeOptions
= SendUserAttributeVerificationCodeOptions;

/// @nodoc
/// {@macro amplify_core.auth.send_user_attribute_verification_code_plugin_options}
@Deprecated('Use SendUserAttributeVerificationCodePluginOptions.')
typedef ResendUserAttributeConfirmationCodePluginOptions
= SendUserAttributeVerificationCodePluginOptions;
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0

import 'package:amplify_core/amplify_core.dart';

part 'send_user_attribute_verification_code_result.g.dart';

/// {@category Auth}
/// {@template amplify_core.send_user_attribute_verification_code_result}
/// Wraps the result of a send user verification code operation.
/// {@endtemplate}
@zAmplifySerializable
class SendUserAttributeVerificationCodeResult
with
AWSEquatable<SendUserAttributeVerificationCodeResult>,
AWSSerializable<Map<String, Object?>>,
AWSDebuggable {
/// {@macro amplify_core.send_user_attribute_verification_code_result}
const SendUserAttributeVerificationCodeResult({
required this.codeDeliveryDetails,
});

/// {@macro amplify_core.send_user_attribute_verification_code_result}
factory SendUserAttributeVerificationCodeResult.fromJson(
Map<String, Object?> json,
) =>
_$SendUserAttributeVerificationCodeResultFromJson(json);

/// Contains the delivery details of the confirmation code that was sent to
/// the user.
final AuthCodeDeliveryDetails codeDeliveryDetails;

@override
List<Object?> get props => [codeDeliveryDetails];

@override
String get runtimeTypeName => 'SendUserAttributeVerificationCodeResult';

@override
Map<String, Object?> toJson() =>
_$SendUserAttributeVerificationCodeResultToJson(this);
}

/// {@macro amplify_core.send_user_attribute_verification_code_result}
@Deprecated('Use SendUserAttributeVerificationCodeResult.')
Jordan-Nelson marked this conversation as resolved.
Show resolved Hide resolved
typedef ResendUserAttributeConfirmationCodeResult
= SendUserAttributeVerificationCodeResult;

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions packages/amplify_core/lib/src/types/auth/auth_types.dart
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ export 'attribute/cognito_user_attribute_key.dart';
export 'attribute/confirm_user_attribute_options.dart';
export 'attribute/confirm_user_attribute_result.dart';
export 'attribute/fetch_user_attributes_options.dart';
export 'attribute/resend_user_attribute_confirmation_code_options.dart';
export 'attribute/resend_user_attribute_confirmation_code_result.dart';
export 'attribute/send_user_attribute_verification_code_options.dart';
export 'attribute/send_user_attribute_verification_code_result.dart';
export 'attribute/update_user_attribute_options.dart';
export 'attribute/update_user_attribute_result.dart';
export 'attribute/update_user_attributes_options.dart';
Expand Down
Loading
Loading