0
Fork 0
mirror of https://github.com/logto-io/logto.git synced 2024-12-30 20:33:54 -05:00

fix(core): handle unexpected user unique identifier error (#6902)

handle unexpected user unqque identifier violation error
This commit is contained in:
simeng-li 2024-12-24 10:00:44 +08:00 committed by GitHub
parent e312a9830b
commit ea5a62bf8a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -57,6 +57,27 @@ export default function koaSlonikErrorHandler<StateT, ContextT>(): Middleware<St
status: 422,
});
}
if (error.constraint === 'users__username') {
throw new RequestError({
code: 'user.username_already_in_use',
status: 422,
});
}
if (error.constraint === 'users__primary_email') {
throw new RequestError({
code: 'user.email_already_in_use',
status: 422,
});
}
if (error.constraint === 'users__primary_phone') {
throw new RequestError({
code: 'user.phone_already_in_use',
status: 422,
});
}
}
if (error instanceof CheckIntegrityConstraintViolationError) {