Fixed incorrect variable & also clears old errors now

pull/250/head
Alex van Andel 2021-06-09 20:32:02 +00:00
parent 28eec8ed7f
commit f24ca5b672
2 changed files with 5 additions and 2 deletions

View File

@ -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,

View File

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