Merge pull request #250 from emrysal/hotfix/username-taken-always-thrown
commit
4448175377
|
@ -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,
|
||||||
|
|
|
@ -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);
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue