Skip to content

Commit

Permalink
worked on review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
harsh62 committed Aug 29, 2023
1 parent 6d0c04a commit b554955
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down

0 comments on commit b554955

Please sign in to comment.