feat: allow associating an existing device ID and token with a username

This commit is contained in:
2024-06-16 08:24:28 -04:00
parent e8aebac6d4
commit f9d7a6bbd2
4 changed files with 112 additions and 7 deletions

View File

@@ -69,11 +69,7 @@ app.openapi(route, async (c) => {
await saveToken(env(c, "workerd"), deviceId, token, username);
} catch (error) {
// when token already exists in the database
if (
error.code === "SQLITE_CONSTRAINT" &&
error.message.includes("device_tokens.token")
) {
if (error.message === "Token already exists in the database") {
return c.json(ErrorResponse, 412);
}