Skip to content

Commit 7fef263

Browse files
authored
Merge pull request #224 from Prz-droid/bug-issue
fix: correct username uniqueness check and field assignment in registration
2 parents b83caab + d40cea8 commit 7fef263

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

app/lib/auth-config.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,15 @@ export const authConfig = {
200200

201201
// If user doesn't exist and this is a registration attempt, create user
202202
if (!user && username) {
203+
// Check if username is already taken
204+
const existingUsername = await prisma.user.findUnique({
205+
where: { username },
206+
});
207+
208+
if (existingUsername) {
209+
throw new Error("Username already taken");
210+
}
211+
203212
user = await prisma.user.create({
204213
data: {
205214
walletAddress,

0 commit comments

Comments
 (0)