Skip to content

Instantly share code, notes, and snippets.

@dnys1
Created June 5, 2023 23:02
Show Gist options
  • Save dnys1/af9c5044e25631da2e6626d9939c0b7e to your computer and use it in GitHub Desktop.
Save dnys1/af9c5044e25631da2e6626d9939c0b7e to your computer and use it in GitHub Desktop.
bustling-aurora-9307

bustling-aurora-9307

Created with <3 with dartpad.dev.

enum MfaType { sms, totp }
T _useCurrent<T>(T value) => value;
Future<void> setMfaPreferences({
Set<MfaType> Function(Set<MfaType>) enabled = _useCurrent,
MfaType? Function(MfaType?) preferred = _useCurrent,
}) async {
// TODO
}
Future<void> main() async {
// To enable SMS MFA without affecting other settings.
await setMfaPreferences(
enabled: (enabled) => enabled..add(MfaType.sms),
);
// To disable SMS MFA without affecting other settings.
await setMfaPreferences(
enabled: (enabled) => enabled..remove(MfaType.sms),
);
// To make SMS MFA the only method, overriding previous values.
await setMfaPreferences(
enabled: (_) => {MfaType.sms},
preferred: (_) => null,
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment