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

Virtual methods for CognitoUser #49

Merged
merged 1 commit into from
Mar 22, 2021
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
28 changes: 14 additions & 14 deletions src/Amazon.Extensions.CognitoAuthentication/CognitoUser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ public CognitoUser(string userID, string clientID,
/// </summary>
/// <param name="confirmationCode">Confirmation code sent to user via email or SMS</param>
/// <param name="forcedAliasCreation">Boolean specifying whether forced alias creation is desired</param>
public Task ConfirmSignUpAsync(string confirmationCode, bool forcedAliasCreation)
public virtual Task ConfirmSignUpAsync(string confirmationCode, bool forcedAliasCreation)
{
ConfirmSignUpRequest confirmRequest = CreateConfirmSignUpRequest(confirmationCode, forcedAliasCreation);

Expand All @@ -174,7 +174,7 @@ public Task ConfirmSignUpAsync(string confirmationCode, bool forcedAliasCreation
/// Request to resend registration confirmation code for a user using an asynchronous call
/// </summary>
/// <returns>Returns the delivery details for the confirmation code request</returns>
public Task ResendConfirmationCodeAsync()
public virtual Task ResendConfirmationCodeAsync()
{
ResendConfirmationCodeRequest resendRequest = CreateResendConfirmationCodeRequest();

Expand All @@ -185,7 +185,7 @@ public Task ResendConfirmationCodeAsync()
/// Allows the user to reset their password using an asynchronous call. Should be used in
/// conjunction with the ConfirmPasswordAsync method
/// </summary>
public Task ForgotPasswordAsync()
public virtual Task ForgotPasswordAsync()
{
ForgotPasswordRequest forgotPassRequest = CreateForgotPasswordRequest();

Expand All @@ -198,7 +198,7 @@ public Task ForgotPasswordAsync()
/// </summary>
/// <param name="confirmationCode">The confirmation code sent to the suer</param>
/// <param name="newPassword">The new desired password for the user</param>
public Task ConfirmForgotPasswordAsync(string confirmationCode, string newPassword)
public virtual Task ConfirmForgotPasswordAsync(string confirmationCode, string newPassword)
{
ConfirmForgotPasswordRequest confirmResetPassRequest =
CreateConfirmPasswordRequest(confirmationCode, newPassword);
Expand All @@ -212,7 +212,7 @@ public Task ConfirmForgotPasswordAsync(string confirmationCode, string newPasswo
/// </summary>
/// <param name="oldPass">The user's old password</param>
/// <param name="newPass">The desired new password</param>
public Task ChangePasswordAsync(string oldPass, string newPass)
public virtual Task ChangePasswordAsync(string oldPass, string newPass)
{
ChangePasswordRequest changePassRequest = CreateChangePasswordRequest(oldPass, newPass);

Expand All @@ -223,7 +223,7 @@ public Task ChangePasswordAsync(string oldPass, string newPass)
/// Gets the details for the current user using an asynchronous call
/// </summary>
/// <returns>Returns a tuple containing the user attributes and settings, in that order</returns>
public Task<GetUserResponse> GetUserDetailsAsync()
public virtual Task<GetUserResponse> GetUserDetailsAsync()
{
EnsureUserAuthenticated();

Expand All @@ -242,7 +242,7 @@ public Task<GetUserResponse> GetUserDetailsAsync()
/// <param name="medium">Name of the attribute the verification code is being sent to.
/// Should be either email or phone_number.</param>
/// <returns>Returns the delivery details for the attribute verification code request</returns>
public Task GetAttributeVerificationCodeAsync(string medium)
public virtual Task GetAttributeVerificationCodeAsync(string medium)
{
GetUserAttributeVerificationCodeRequest getAttributeCodeRequest =
CreateGetUserAttributeVerificationCodeRequest(medium);
Expand All @@ -253,7 +253,7 @@ public Task GetAttributeVerificationCodeAsync(string medium)
/// <summary>
/// Sign-out from all devices associated with this user using an asynchronous call
/// </summary>
public Task GlobalSignOutAsync()
public virtual Task GlobalSignOutAsync()
{
EnsureUserAuthenticated();

Expand All @@ -269,7 +269,7 @@ public Task GlobalSignOutAsync()
/// <summary>
/// Deletes the current user using an asynchronous call
/// </summary>
public Task DeleteUserAsync()
public virtual Task DeleteUserAsync()
{
EnsureUserAuthenticated();

Expand All @@ -286,7 +286,7 @@ public Task DeleteUserAsync()
/// </summary>
/// <param name="attributeName">Attribute to be verified. Should either be email or phone_number</param>
/// <param name="verificationCode">The verification code for the attribute being verified</param>
public Task VerifyAttributeAsync(string attributeName, string verificationCode)
public virtual Task VerifyAttributeAsync(string attributeName, string verificationCode)
{
VerifyUserAttributeRequest verifyUserAttributeRequest =
CreateVerifyUserAttributeRequest(attributeName, verificationCode);
Expand All @@ -299,7 +299,7 @@ public Task VerifyAttributeAsync(string attributeName, string verificationCode)
/// using an asynchronous call
/// </summary>
/// <param name="attributes">The attributes to be updated</param>
public async Task UpdateAttributesAsync(IDictionary<string, string> attributes)
public virtual async Task UpdateAttributesAsync(IDictionary<string, string> attributes)
{
UpdateUserAttributesRequest updateUserAttributesRequest =
CreateUpdateUserAttributesRequest(attributes);
Expand All @@ -318,7 +318,7 @@ public async Task UpdateAttributesAsync(IDictionary<string, string> attributes)
/// an asynchronous call
/// </summary>
/// <param name="attributeNamesToDelete">List of attributes to delete</param>
public async Task DeleteAttributesAsync(IList<string> attributeNamesToDelete)
public virtual async Task DeleteAttributesAsync(IList<string> attributeNamesToDelete)
{
DeleteUserAttributesRequest deleteUserAttributesRequest =
CreateDeleteUserAttributesRequest(attributeNamesToDelete);
Expand All @@ -340,7 +340,7 @@ public async Task DeleteAttributesAsync(IList<string> attributeNamesToDelete)
/// using an asynchronous call
/// </summary>
/// <param name="userSettings">Dictionary for the user MFA settings of the form [attribute, delivery medium]</param>
public async Task SetUserSettingsAsync(IDictionary<string, string> userSettings)
public virtual async Task SetUserSettingsAsync(IDictionary<string, string> userSettings)
{
SetUserSettingsRequest setUserSettingsRequest = CreateSetUserSettingsRequest(userSettings);

Expand All @@ -359,7 +359,7 @@ public async Task SetUserSettingsAsync(IDictionary<string, string> userSettings)
/// <param name="limit">Maxmimum number of devices to be returned in this call</param>
/// <param name="paginationToken">Token to continue earlier search</param>
/// <returns>Returns a list of CognitoDevices associated with this user</returns>
public async Task<List<CognitoDevice>> ListDevicesAsync(int limit, string paginationToken)
public virtual async Task<List<CognitoDevice>> ListDevicesAsync(int limit, string paginationToken)
{
ListDevicesRequest listDevicesRequest = CreateListDevicesRequest(limit, paginationToken);
ListDevicesResponse listDevicesReponse = await Provider.ListDevicesAsync(listDevicesRequest).ConfigureAwait(false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ partial class CognitoUser
/// create an InitiateAuthAsync API call for SRP authentication</param>
/// <returns>Returns the AuthFlowResponse object that can be used to respond to the next challenge,
/// if one exists</returns>
public async Task<AuthFlowResponse> StartWithSrpAuthAsync(InitiateSrpAuthRequest srpRequest)
public virtual async Task<AuthFlowResponse> StartWithSrpAuthAsync(InitiateSrpAuthRequest srpRequest)
{
if (srpRequest == null || string.IsNullOrEmpty(srpRequest.Password))
{
Expand Down Expand Up @@ -77,7 +77,7 @@ public async Task<AuthFlowResponse> StartWithSrpAuthAsync(InitiateSrpAuthRequest
/// create an InitiateAuthAsync API call for custom authentication</param>
/// <returns>Returns the AuthFlowResponse object that can be used to respond to the next challenge,
/// if one exists</returns>
public async Task<AuthFlowResponse> StartWithCustomAuthAsync(InitiateCustomAuthRequest customRequest)
public virtual async Task<AuthFlowResponse> StartWithCustomAuthAsync(InitiateCustomAuthRequest customRequest)
{
InitiateAuthRequest authRequest = new InitiateAuthRequest()
{
Expand Down Expand Up @@ -107,7 +107,7 @@ public async Task<AuthFlowResponse> StartWithCustomAuthAsync(InitiateCustomAuthR
/// respond to the current custom authentication challenge</param>
/// <returns>Returns the AuthFlowResponse object that can be used to respond to the next challenge,
/// if one exists</returns>
public async Task<AuthFlowResponse> RespondToCustomAuthAsync(RespondToCustomChallengeRequest customRequest)
public virtual async Task<AuthFlowResponse> RespondToCustomAuthAsync(RespondToCustomChallengeRequest customRequest)
{
RespondToAuthChallengeRequest request = new RespondToAuthChallengeRequest()
{
Expand Down Expand Up @@ -137,7 +137,7 @@ public async Task<AuthFlowResponse> RespondToCustomAuthAsync(RespondToCustomChal
/// respond to the current SMS MFA authentication challenge</param>
/// <returns>Returns the AuthFlowResponse object that can be used to respond to the next challenge,
/// if one exists</returns>
public async Task<AuthFlowResponse> RespondToSmsMfaAuthAsync(RespondToSmsMfaRequest smsMfaRequest)
public virtual async Task<AuthFlowResponse> RespondToSmsMfaAuthAsync(RespondToSmsMfaRequest smsMfaRequest)
{
RespondToAuthChallengeRequest challengeRequest = new RespondToAuthChallengeRequest
{
Expand Down Expand Up @@ -176,7 +176,7 @@ public async Task<AuthFlowResponse> RespondToSmsMfaAuthAsync(RespondToSmsMfaRequ
/// parameters to respond to the current SMS MFA authentication challenge</param>
/// <returns>Returns the AuthFlowResponse object that can be used to respond to the next challenge,
/// if one exists</returns>
public Task<AuthFlowResponse> RespondToNewPasswordRequiredAsync(RespondToNewPasswordRequiredRequest newPasswordRequest)
public virtual Task<AuthFlowResponse> RespondToNewPasswordRequiredAsync(RespondToNewPasswordRequiredRequest newPasswordRequest)
{
return RespondToNewPasswordRequiredAsync(newPasswordRequest, null);
}
Expand All @@ -191,7 +191,7 @@ public Task<AuthFlowResponse> RespondToNewPasswordRequiredAsync(RespondToNewPass
/// parameters to respond to the current SMS MFA authentication challenge</param>
/// <returns>Returns the AuthFlowResponse object that can be used to respond to the next challenge,
/// if one exists</returns>
public async Task<AuthFlowResponse> RespondToNewPasswordRequiredAsync(RespondToNewPasswordRequiredRequest newPasswordRequest, Dictionary<string, string> requiredAttributes)
public virtual async Task<AuthFlowResponse> RespondToNewPasswordRequiredAsync(RespondToNewPasswordRequiredRequest newPasswordRequest, Dictionary<string, string> requiredAttributes)
{
var challengeResponses = new Dictionary<string, string>()
{
Expand Down Expand Up @@ -240,7 +240,7 @@ public async Task<AuthFlowResponse> RespondToNewPasswordRequiredAsync(RespondToN
/// parameters to initiate the refresh token authentication flow</param>
/// <returns>Returns the AuthFlowResponse object that can be used to respond to the next challenge,
/// if one exists</returns>
public async Task<AuthFlowResponse> StartWithRefreshTokenAuthAsync(InitiateRefreshTokenAuthRequest refreshTokenRequest)
public virtual async Task<AuthFlowResponse> StartWithRefreshTokenAuthAsync(InitiateRefreshTokenAuthRequest refreshTokenRequest)
{
InitiateAuthRequest initiateAuthRequest = CreateRefreshTokenAuthRequest(refreshTokenRequest.AuthFlowType);

Expand All @@ -263,7 +263,7 @@ public async Task<AuthFlowResponse> StartWithRefreshTokenAuthAsync(InitiateRefre
/// parameters to initiate the ADMIN_NO_SRP_AUTH authentication flow</param>
/// <returns>Returns the AuthFlowResponse object that can be used to respond to the next challenge,
/// if one exists</returns>
public async Task<AuthFlowResponse> StartWithAdminNoSrpAuthAsync(InitiateAdminNoSrpAuthRequest adminAuthRequest)
public virtual async Task<AuthFlowResponse> StartWithAdminNoSrpAuthAsync(InitiateAdminNoSrpAuthRequest adminAuthRequest)
{
AdminInitiateAuthRequest initiateAuthRequest = CreateAdminAuthRequest(adminAuthRequest);

Expand Down