From b5549551eacd8fa206a7d3b71b9b99687e050155 Mon Sep 17 00:00:00 2001 From: Harshdeep Singh <6162866+harsh62@users.noreply.github.com> Date: Tue, 29 Aug 2023 17:28:01 -0400 Subject: [PATCH] worked on review comments --- .../Sources/AWSCognitoAuthPlugin/Models/MFAPreference.swift | 6 +++--- .../AWSCognitoAuthPlugin/Task/UpdateMFAPreferenceTask.swift | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/AmplifyPlugins/Auth/Sources/AWSCognitoAuthPlugin/Models/MFAPreference.swift b/AmplifyPlugins/Auth/Sources/AWSCognitoAuthPlugin/Models/MFAPreference.swift index 26bc925e45..f91dd8a889 100644 --- a/AmplifyPlugins/Auth/Sources/AWSCognitoAuthPlugin/Models/MFAPreference.swift +++ b/AmplifyPlugins/Auth/Sources/AWSCognitoAuthPlugin/Models/MFAPreference.swift @@ -27,10 +27,10 @@ public enum MFAPreference { extension MFAPreference { - func smsSetting(isCurrentlyPreferred: Bool? = nil) -> CognitoIdentityProviderClientTypes.SMSMfaSettingsType? { + func smsSetting(isCurrentlyPreferred: Bool = false) -> CognitoIdentityProviderClientTypes.SMSMfaSettingsType { switch self { case .enabled: - return .init(enabled: true, preferredMfa: isCurrentlyPreferred ?? false) + return .init(enabled: true, preferredMfa: isCurrentlyPreferred) case .preferred: return .init(enabled: true, preferredMfa: true) case .notPreferred: @@ -40,7 +40,7 @@ extension MFAPreference { } } - func softwareTokenSetting(isCurrentlyPreferred: Bool? = nil) -> CognitoIdentityProviderClientTypes.SoftwareTokenMfaSettingsType? { + func softwareTokenSetting(isCurrentlyPreferred: Bool? = nil) -> CognitoIdentityProviderClientTypes.SoftwareTokenMfaSettingsType { switch self { case .enabled: return .init(enabled: true, preferredMfa: isCurrentlyPreferred ?? false) diff --git a/AmplifyPlugins/Auth/Sources/AWSCognitoAuthPlugin/Task/UpdateMFAPreferenceTask.swift b/AmplifyPlugins/Auth/Sources/AWSCognitoAuthPlugin/Task/UpdateMFAPreferenceTask.swift index a3d06e9bec..de0774fb7a 100644 --- a/AmplifyPlugins/Auth/Sources/AWSCognitoAuthPlugin/Task/UpdateMFAPreferenceTask.swift +++ b/AmplifyPlugins/Auth/Sources/AWSCognitoAuthPlugin/Task/UpdateMFAPreferenceTask.swift @@ -62,7 +62,7 @@ class UpdateMFAPreferenceTask: AuthUpdateMFAPreferenceTask, DefaultLogger { func updateMFAPreference(with accessToken: String) async throws { let userPoolService = try userPoolFactory() let currentPreference = try await userPoolService.getUser(input: .init(accessToken: accessToken)) - let preferredMFAType = MFAType(rawValue: currentPreference.preferredMfaSetting ?? "") + let preferredMFAType = currentPreference.preferredMfaSetting.map(MFAType.init(rawValue:)) let input = SetUserMFAPreferenceInput( accessToken: accessToken, smsMfaSettings: smsPreference?.smsSetting(isCurrentlyPreferred: preferredMFAType == .sms),