delete account ui functionality

This commit is contained in:
2023-05-28 23:21:59 +02:00
parent b3f740770a
commit 06bfd4cd9e
6 changed files with 63 additions and 30 deletions

View File

@@ -69,10 +69,12 @@ export const encryptionKey = ref<EncryptionKey | null>()
export async function getEncryptionKey() {
encryptedEncryptionKey.value = (await getEncryptedEncryptionKey()) || undefined
if (!encryptedEncryptionKey.value || !clientKey.value) {
if (encryptedEncryptionKey.value && clientKey.value) {
encryptionKey.value = decrypt(encryptedEncryptionKey.value, clientKey.value)
} else if (!encryptedEncryptionKey.value) {
encryptionKey.value = null
} else {
encryptionKey.value = decrypt(encryptedEncryptionKey.value, clientKey.value)
encryptionKey.value = undefined
}
}

View File

@@ -263,6 +263,7 @@ export const getNotes = async () => {
if (encryptionKey.value === undefined || !user.value || !db.value) return
const firebaseNotes = (await getDoc(doc(db.value, 'pages', user.value.uid))).data() as BaseNotes
notes = encryptionKey.value ? decryptNotes(firebaseNotes, encryptionKey.value) : firebaseNotes
console.log(encryptionKey.value)
console.log('get notes from firebase', notes)
}
baseNotes.value = parseBaseNotes(notes)