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); });