Layout: Don't check for username/firstname in profile update handler
All checks were successful
Build Formula11 Docker Image / pocketbase-docker (push) Successful in 29s

This commit is contained in:
2025-02-27 01:11:50 +01:00
parent d4d44a79f6
commit 780706ce4a

View File

@ -164,15 +164,6 @@
const update_profile = (create?: boolean): (() => Promise<void>) => { const update_profile = (create?: boolean): (() => Promise<void>) => {
const handler = async (): Promise<void> => { const handler = async (): Promise<void> => {
if (!username_value || username_value === "") {
toastStore.trigger(get_error_toast("Please enter a username!"));
return;
}
if (!firstname_value || firstname_value === "") {
toastStore.trigger(get_error_toast("Please enter your first name!"));
return;
}
// Avatar handling // Avatar handling
let avatar_avif: Blob | undefined = undefined; let avatar_avif: Blob | undefined = undefined;
const avatar_file: File | undefined = const avatar_file: File | undefined =
@ -202,6 +193,14 @@
try { try {
if (create) { if (create) {
if (!username_value || username_value === "") {
toastStore.trigger(get_error_toast("Please enter a username!"));
return;
}
if (!firstname_value || firstname_value === "") {
toastStore.trigger(get_error_toast("Please enter your first name!"));
return;
}
if (!password_value || password_value === "") { if (!password_value || password_value === "") {
toastStore.trigger(get_error_toast("Please enter a password!")); toastStore.trigger(get_error_toast("Please enter a password!"));
return; return;
@ -223,8 +222,8 @@
} }
await pb.collection("users").update(data.user.id, { await pb.collection("users").update(data.user.id, {
username: username_value, username: username_value.length > 0 ? username_value : undefined,
firstname: firstname_value, firstname: firstname_value.length > 0 ? firstname_value : undefined,
avatar: avatar_avif, avatar: avatar_avif,
}); });
drawerStore.close(); drawerStore.close();