LoginTwoFactorMethods.vue 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. <!-- Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/ -->
  2. <script setup lang="ts">
  3. import type { TwoFactorPlugin } from '#shared/entities/two-factor/types.ts'
  4. import type { EnumTwoFactorAuthenticationMethod } from '#shared/graphql/types.ts'
  5. import CommonButton from '#desktop/components/CommonButton/CommonButton.vue'
  6. defineProps<{
  7. methods: TwoFactorPlugin[]
  8. defaultMethod?: Maybe<EnumTwoFactorAuthenticationMethod>
  9. recoveryCodesAvailable: boolean
  10. }>()
  11. const emit = defineEmits<{
  12. select: [twoFactorMethod: EnumTwoFactorAuthenticationMethod]
  13. cancel: []
  14. 'use-recovery-code': []
  15. }>()
  16. </script>
  17. <template>
  18. <section
  19. v-for="method of methods"
  20. :key="method.name"
  21. class="mt-3 flex flex-col"
  22. >
  23. <CommonButton
  24. size="large"
  25. block
  26. :prefix-icon="method.icon"
  27. :variant="method.name == defaultMethod ? 'primary' : 'tertiary'"
  28. @click="emit('select', method.name)"
  29. >
  30. {{ $t(method.label) }}
  31. </CommonButton>
  32. <div v-if="method.description" class="mt-2.5 text-center">
  33. <CommonLabel>
  34. {{ $t(method.description) }}
  35. </CommonLabel>
  36. </div>
  37. </section>
  38. <div class="mt-8 text-center text-sm">
  39. <CommonLink
  40. v-if="recoveryCodesAvailable"
  41. link="#"
  42. @click="emit('use-recovery-code')"
  43. >
  44. {{ $t('Or use one of your recovery codes.') }}
  45. </CommonLink>
  46. </div>
  47. <CommonButton class="mt-5" size="large" block @click="emit('cancel')">
  48. {{ $t('Cancel & Go Back') }}
  49. </CommonButton>
  50. </template>