From 315728415b2269981a04ee51af7ef18412d7bf70 Mon Sep 17 00:00:00 2001 From: Willy Woitas Date: Sun, 18 Feb 2024 01:49:42 +0100 Subject: feat: Parse 2FA SMS token and copy to clipboard (#1561) --- .../settings/settings/EditSettingsForm.tsx | 24 +++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) (limited to 'src/components') diff --git a/src/components/settings/settings/EditSettingsForm.tsx b/src/components/settings/settings/EditSettingsForm.tsx index 6a79fcc8f..81cfe8b12 100644 --- a/src/components/settings/settings/EditSettingsForm.tsx +++ b/src/components/settings/settings/EditSettingsForm.tsx @@ -303,6 +303,8 @@ interface IProps extends WrappedComponentProps { isClearingAllCache: boolean; isTodosActivated: boolean; automaticUpdates: boolean; + isTwoFactorAutoCatcherEnabled: boolean; + twoFactorAutoCatcherMatcher: string; isDarkmodeEnabled: boolean; isAdaptableDarkModeEnabled: boolean; isUseGrayscaleServicesEnabled: boolean; @@ -354,7 +356,8 @@ class EditSettingsForm extends Component { this.props.form.submit({ onSuccess: (form: Form) => { const values = form.values(); - const { accentColor } = values; + const { accentColor, isTwoFactorAutoCatcherEnabled } = values; + if (accentColor.trim().length === 0) { values.accentColor = DEFAULT_ACCENT_COLOR; } @@ -362,6 +365,15 @@ class EditSettingsForm extends Component { if (progressbarAccentColor.trim().length === 0) { values.progressbarAccentColor = DEFAULT_ACCENT_COLOR; } + + // set twoFactorAutoCatcherMatcher to the default value, if its get enabled the input is prefilled + if ( + !isTwoFactorAutoCatcherEnabled && + values.twoFactorAutoCatcherMatcher.length === 0 + ) { + values.twoFactorAutoCatcherMatcher = + DEFAULT_APP_SETTINGS.twoFactorAutoCatcherMatcher; + } this.props.onSubmit(values); }, onError: noop, @@ -386,6 +398,7 @@ class EditSettingsForm extends Component { onClearAllCache, getCacheSize, automaticUpdates, + isTwoFactorAutoCatcherEnabled, isDarkmodeEnabled, isSplitModeEnabled, openProcessManager, @@ -837,6 +850,15 @@ class EditSettingsForm extends Component { )} + + + {isTwoFactorAutoCatcherEnabled && ( + this.submit(e)} + {...form.$('twoFactorAutoCatcherMatcher').bind()} + /> + )} +