mirror of
https://github.com/cupcakearmy/cryptgeon.git
synced 2025-09-05 17:00:39 +00:00
dont' allow empty notes
This commit is contained in:
@@ -46,12 +46,15 @@
|
||||
note.contents = ''
|
||||
}
|
||||
|
||||
class EmptyContentError extends Error {}
|
||||
|
||||
async function submit() {
|
||||
try {
|
||||
error = null
|
||||
loading = true
|
||||
const password = Hex.encode(getRandomBytes(32))
|
||||
const key = await getKeyFromString(password)
|
||||
if (note.contents === '') throw new EmptyContentError()
|
||||
const data: Note = {
|
||||
contents: await encrypt(note.contents, key),
|
||||
meta: note.meta,
|
||||
@@ -67,6 +70,8 @@
|
||||
} catch (e) {
|
||||
if (e instanceof PayloadToLargeError) {
|
||||
error = $t('home.errors.note_to_big')
|
||||
} else if (e instanceof EmptyContentError) {
|
||||
error = $t('home.errors.empty_content')
|
||||
} else {
|
||||
error = $t('home.errors.note_error')
|
||||
}
|
||||
|
Reference in New Issue
Block a user