Merge pull request #250 from emrysal/hotfix/username-taken-always-thrown

pull/253/head^2
Bailey Pumfleet 2021-06-09 21:33:40 +01:00 committed by GitHub
commit 4448175377
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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; const username = req.body.username;
// username is changed: username is optional but it is necessary to be unique, enforce here // 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({ const userConflict = await prisma.user.findFirst({
where: { where: {
username, username,

View File

@ -58,7 +58,10 @@ export default function Settings(props) {
headers: { headers: {
'Content-Type': 'application/json' '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); setHasErrors(true);
setErrorMessage(err.message); setErrorMessage(err.message);
}); });