Skip to content
This repository was archived by the owner on Feb 4, 2025. It is now read-only.

Commit ec3f446

Browse files
committed
fix(server): add additional guards in exception handling
1 parent 85edaa3 commit ec3f446

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

server/auth/register.ts

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,17 @@ export const register = async (
1818
perms: 0
1919
})
2020
} catch (e) {
21-
if (e.constraint === 'users_ctftime_id_key') {
22-
return responses.badKnownCtftimeId
23-
}
24-
if (e.constraint === 'users_email_key') {
25-
return responses.badKnownEmail
26-
}
27-
if (e.constraint === 'users_name_key') {
28-
return responses.badKnownName
21+
if (e instanceof Object) {
22+
const { constraint } = e as { constraint?: string }
23+
if (constraint === 'users_ctftime_id_key') {
24+
return responses.badKnownCtftimeId
25+
}
26+
if (constraint === 'users_email_key') {
27+
return responses.badKnownEmail
28+
}
29+
if (constraint === 'users_name_key') {
30+
return responses.badKnownName
31+
}
2932
}
3033
throw e
3134
}

0 commit comments

Comments
 (0)