Pārlūkot izejas kodu

fix: do not popup otp modal if user not enable 2fa

Jacky 9 mēneši atpakaļ
vecāks
revīzija
afd6bf4268

+ 8 - 1
app/src/components/OTP/useOTPModal.ts

@@ -24,7 +24,14 @@ const useOTPModal = () => {
     document.head.appendChild(style)
   }
 
-  const open = ({ onOk, onCancel }: OTPModalProps) => {
+  const open = async ({ onOk, onCancel }: OTPModalProps) => {
+    const { status } = await otp.status()
+    if (!status) {
+      onOk?.('')
+
+      return
+    }
+
     const cookies = useCookies(['nginx-ui-2fa'])
     const ssid = cookies.get('secure_session_id')
     if (ssid) {

+ 2 - 2
app/src/views/preference/AuthSettings.vue

@@ -55,6 +55,8 @@ function removeBannedIP(ip: string) {
 <template>
   <div class="flex justify-center">
     <div>
+      <TOTP class="mb-4" />
+
       <AAlert
         class="mb-4"
         :message="$gettext('Tips')"
@@ -106,8 +108,6 @@ function removeBannedIP(ip: string) {
           </template>
         </ATable>
       </div>
-
-      <TOTP />
     </div>
   </div>
 </template>