Skip to content

Commit

Permalink
Merge pull request #250 from emrysal/hotfix/username-taken-always-thrown
Browse files Browse the repository at this point in the history
  • Loading branch information
baileypumfleet committed Jun 9, 2021
2 parents 28eec8e + f24ca5b commit 4448175
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion pages/api/user/profile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
5 changes: 4 additions & 1 deletion pages/settings/profile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
Expand Down

1 comment on commit 4448175

@vercel
Copy link

@vercel vercel bot commented on 4448175 Jun 9, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.