Skip to content

Commit

Permalink
cleanup and make sure not to cause a DB failure
Browse files Browse the repository at this point in the history
  • Loading branch information
Adammatthiesen committed May 9, 2024
1 parent 9d9305f commit 837fe5c
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export async function POST(context: APIContext): Promise<Response> {
if (existingUser) {
return new Response(
JSON.stringify({
error: "Username already used"
error: "Username/Email already used"
}),
{
status: 400
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,9 @@ const clientDomain = `https://${NoHTTPDOMAIN}`;
}

const existingUserName = await db.select().from(User).where(eq(User.username, username)).get();
const existingUserByEmail = await db.select().from(User).where(eq(User.email, email)).get();

if (existingUserName) {
if (existingUserName || existingUserByEmail) {
return new Response("User already exists", {
status: 400,
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,9 @@ export async function GET(context: APIContext): Promise<Response> {
}

const existingUserByUsername = await db.select().from(User).where(eq(User.username, username)).get();
const existingUserByEmail = await db.select().from(User).where(eq(User.email, email)).get();

if (existingUserByUsername) {
if (existingUserByUsername || existingUserByEmail) {
return new Response("User already exists", {
status: 400,
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,9 @@ export async function GET(context: APIContext): Promise<Response> {
}

const existingUserName = await db.select().from(User).where(eq(User.username, username)).get();
const existingUserByEmail = await db.select().from(User).where(eq(User.email, email)).get();

if (existingUserName) {
if (existingUserName || existingUserByEmail) {
return new Response("User already exists", {
status: 400,
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,9 @@ export async function GET(context: APIContext): Promise<Response> {
const username = `g_${fixname}`

const existingUserName = await db.select().from(User).where(eq(User.username, username)).get();
const existingUserByEmail = await db.select().from(User).where(eq(User.email, email)).get();

if (existingUserName) {
if (existingUserName || existingUserByEmail) {
return new Response("User already exists", {
status: 400,
});
Expand Down
6 changes: 3 additions & 3 deletions playgrounds/node/.env.demo
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# OPTIONALS

# credentials for GitHub OAuth
CMS_GITHUB_CLIENT_ID=
CMS_GITHUB_CLIENT_SECRET=http://localhost:4321/dashboard/login/github/callback
CMS_GITHUB_CLIENT_SECRET=
# Github Callback URL `http://localhost:4321/dashboard/login/github/callback`
# Github callback URL is NOT AN ENV VARIABLE!

# credentials for Discord OAuth
CMS_DISCORD_CLIENT_ID=
Expand Down

0 comments on commit 837fe5c

Please sign in to comment.