Skip to content

Commit e1d0501

Browse files
committed
fix: update recovery code validation logic for disabling TOTP
1 parent 02e1323 commit e1d0501

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

dashboard/src/components/shared/DashboardTotpDisableDialog.vue

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
color="error"
4343
variant="tonal"
4444
:loading="verifying"
45-
:disabled="!recoveryCode || recoveryCode.length < 5"
45+
:disabled="!isValidRecoveryCode"
4646
@click="confirmDisable"
4747
>
4848
{{ tm('system_group.system.dashboard.totp.disableConfirm') }}
@@ -91,7 +91,7 @@
9191
</template>
9292

9393
<script setup>
94-
import { ref } from 'vue'
94+
import { computed, ref } from 'vue'
9595
import axios from 'axios'
9696
import { useModuleI18n } from '@/i18n/composables'
9797
@@ -104,6 +104,12 @@ const showRecovery = ref(false)
104104
const verifying = ref(false)
105105
const errorMsg = ref('')
106106
107+
const isValidRecoveryCode = computed(() => {
108+
if (!recoveryCode.value) return false
109+
const normalized = recoveryCode.value.replace(/[^A-Za-z0-9]/g, '')
110+
return normalized.length === 32
111+
})
112+
107113
function resetState() {
108114
code.value = ''
109115
recoveryCode.value = ''

0 commit comments

Comments
 (0)