summaryrefslogtreecommitdiff
path: root/packages/frontend/src/pages/settings/2fa.qrdialog.vue
blob: 1d836db5f5d78da89329c8b5f5925f8343438bb1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
<template>
<MkModal
	ref="dialogEl"
	:prefer-type="'dialog'"
	:z-priority="'low'"
	@click="cancel"
	@close="cancel"
	@closed="emit('closed')"
>
	<div :class="$style.root" class="_gaps_m">
		<I18n :src="i18n.ts._2fa.step1" tag="div">
			<template #a>
				<a href="https://authy.com/" rel="noopener" target="_blank" class="_link">Authy</a>
			</template>
			<template #b>
				<a href="https://support.google.com/accounts/answer/1066447" rel="noopener" target="_blank" class="_link">Google Authenticator</a>
			</template>
		</I18n>
		<div>
			{{ i18n.ts._2fa.step2 }}<br>
			{{ i18n.ts._2fa.step2Click }}
		</div>
		<a :href="twoFactorData.url"><img :class="$style.qr" :src="twoFactorData.qr"></a>
		<MkKeyValue :copy="twoFactorData.url">
			<template #key>{{ i18n.ts._2fa.step2Url }}</template>
			<template #value>{{ twoFactorData.url }}</template>
		</MkKeyValue>
		<div class="_buttons">
			<MkButton primary @click="ok">{{ i18n.ts.next }}</MkButton>
			<MkButton @click="cancel">{{ i18n.ts.cancel }}</MkButton>
		</div>
	</div>
</MkModal>
</template>

<script lang="ts" setup>
import MkButton from '@/components/MkButton.vue';
import MkModal from '@/components/MkModal.vue';
import MkKeyValue from '@/components/MkKeyValue.vue';
import { i18n } from '@/i18n';

defineProps<{
	twoFactorData: {
		qr: string;
		url: string;
	};
}>();

const emit = defineEmits<{
	(ev: 'ok'): void;
	(ev: 'cancel'): void;
	(ev: 'closed'): void;
}>();

const cancel = () => {
	emit('cancel');
	emit('closed');
};

const ok = () => {
	emit('ok');
	emit('closed');
};
</script>

<style lang="scss" module>
.root {
	position: relative;
	margin: auto;
	padding: 32px;
	min-width: 320px;
	max-width: calc(100svw - 64px);
	box-sizing: border-box;
	background: var(--panel);
	border-radius: var(--radius);
}

.qr {
    width: 20em;
    max-width: 100%;
}
</style>