From f24ca5b6721d0f66c5f251a7e0c65fa4b39b7c70 Mon Sep 17 00:00:00 2001 From: Alex van Andel Date: Wed, 9 Jun 2021 20:32:02 +0000 Subject: [PATCH] Fixed incorrect variable & also clears old errors now --- pages/api/user/profile.ts | 2 +- pages/settings/profile.tsx | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/pages/api/user/profile.ts b/pages/api/user/profile.ts index fb47f5d221..cc9aef6a5d 100644 --- a/pages/api/user/profile.ts +++ b/pages/api/user/profile.ts @@ -25,7 +25,7 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse) const username = req.body.username; // username is changed: username is optional but it is necessary to be unique, enforce here - if (username !== user.username) { + if (username !== session.user.username) { const userConflict = await prisma.user.findFirst({ where: { username, diff --git a/pages/settings/profile.tsx b/pages/settings/profile.tsx index 2078796636..a00f9efaf6 100644 --- a/pages/settings/profile.tsx +++ b/pages/settings/profile.tsx @@ -58,7 +58,10 @@ export default function Settings(props) { headers: { 'Content-Type': 'application/json' } - }).then(handleError).then( () => setSuccessModalOpen(true) ).catch( (err) => { + }).then(handleError).then( () => { + setSuccessModalOpen(true); + setHasErrors(false); // dismiss any open errors + }).catch( (err) => { setHasErrors(true); setErrorMessage(err.message); });