LoginTwoFactorMethods.vue 1.6 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. import CommonLabel from '#shared/components/CommonLabel/CommonLabel.vue'
  7. defineProps<{
  8. methods: TwoFactorPlugin[]
  9. defaultMethod?: Maybe<EnumTwoFactorAuthenticationMethod>
  10. recoveryCodesAvailable: boolean
  11. }>()
  12. const emit = defineEmits<{
  13. (e: 'select', twoFactorMethod: EnumTwoFactorAuthenticationMethod): void
  14. (e: 'cancel'): void
  15. (e: 'use-recovery-code'): void
  16. }>()
  17. </script>
  18. <template>
  19. <section
  20. v-for="method of methods"
  21. :key="method.name"
  22. class="mt-3 flex flex-col"
  23. >
  24. <CommonButton
  25. size="large"
  26. block
  27. :prefix-icon="method.icon"
  28. :variant="method.name == defaultMethod ? 'primary' : 'tertiary'"
  29. @click="emit('select', method.name)"
  30. >
  31. {{ $t(method.label) }}
  32. </CommonButton>
  33. <div class="mt-2.5 text-center">
  34. <CommonLabel>
  35. {{ $t(method.description) }}
  36. </CommonLabel>
  37. </div>
  38. </section>
  39. <div class="mt-8 text-sm text-center">
  40. <CommonLink
  41. v-if="recoveryCodesAvailable"
  42. link="#"
  43. @click="emit('use-recovery-code')"
  44. >
  45. {{ $t('Or use one of your recovery codes.') }}
  46. </CommonLink>
  47. </div>
  48. <CommonButton class="mt-5" size="large" block @click="emit('cancel')">
  49. {{ $t('Cancel & Go Back') }}
  50. </CommonButton>
  51. </template>