/
EnterPassphraseStep.vue
97 lines (83 loc) · 2.96 KB
/
EnterPassphraseStep.vue
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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
// Copyright (C) 2023 Storj Labs, Inc.
// See LICENSE for copying information.
<template>
<v-form ref="form" class="pa-8" @submit.prevent>
<v-row>
<v-col v-if="$slots.default" cols="12">
<slot />
</v-col>
<v-col cols="12">
<v-text-field
id="Encryption Passphrase"
v-model="passphrase"
label="Encryption Passphrase"
:type="isPassphraseVisible ? 'text' : 'password'"
variant="outlined"
:hide-details="false"
:rules="[ RequiredRule ]"
autofocus
required
class="mt-2 mb-n4"
>
<template #append-inner>
<password-input-eye-icons
:is-visible="isPassphraseVisible"
type="passphrase"
@toggleVisibility="isPassphraseVisible = !isPassphraseVisible"
/>
</template>
</v-text-field>
<v-checkbox
v-if="ackRequired"
density="compact"
color="primary"
label="I saved my encryption passphrase."
:hide-details="false"
:rules="[ RequiredRule ]"
class="mt-4 mb-n7"
/>
</v-col>
</v-row>
</v-form>
</template>
<script setup lang="ts">
import { ref, watch } from 'vue';
import { VForm, VRow, VCol, VTextField, VCheckbox } from 'vuetify/components';
import { RequiredRule, DialogStepComponent } from '@/types/common';
import { useBucketsStore } from '@/store/modules/bucketsStore';
import { EdgeCredentials } from '@/types/accessGrants';
import { useNotify } from '@/utils/hooks';
import PasswordInputEyeIcons from '@/components/PasswordInputEyeIcons.vue';
const bucketsStore = useBucketsStore();
const notify = useNotify();
const form = ref<VForm | null>(null);
const passphrase = ref<string>('');
const isPassphraseVisible = ref<boolean>(false);
const props = withDefaults(defineProps<{
title: string;
setOnNext: boolean;
ackRequired: boolean;
}>(), {
title: 'Enter New Passphrase',
setOnNext: false,
ackRequired: false,
});
const emit = defineEmits<{
'passphraseChanged': [passphrase: string];
}>();
watch(passphrase, value => emit('passphraseChanged', value));
defineExpose<DialogStepComponent>({
title: props.title,
validate: () => {
form.value?.validate();
return !!form.value?.isValid;
},
onExit: to => {
if (!props.setOnNext || to !== 'next') return;
bucketsStore.setEdgeCredentials(new EdgeCredentials());
bucketsStore.setPassphrase(passphrase.value);
bucketsStore.setPromptForPassphrase(false);
notify.success('Passphrase switched.');
},
});
</script>