Fixed incorrect variable & also clears old errors now
parent
28eec8ed7f
commit
f24ca5b672
|
@ -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,
|
||||
|
|
|
@ -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);
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue