Skip to content

Commit

Permalink
fix: initial login oopsies
Browse files Browse the repository at this point in the history
  • Loading branch information
veryCrunchy committed Apr 27, 2024
1 parent 3aa5b25 commit 45c343a
Showing 1 changed file with 8 additions and 11 deletions.
19 changes: 8 additions & 11 deletions src/routes/callback.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,20 +146,17 @@ router.get("/login/callback", async (req: Request, res: Response) => {
refreshToken: tokens.refreshToken,
expiresAt: tokens.accessTokenExpiresAt,
scope: storedScopes,
userId,
});

// Update the user with the primaryAccountId obtained from the inserted account
if (!userId) {
await transaction.insert(schema.users).values({
id: userId,
primaryAccountId: user.id,
});
await transaction
.update(schema.accounts)
.set({ userId })
.where(eq(schema.accounts.id, user.id));
}
await transaction.insert(schema.users).values({
id: userId,
primaryAccountId: user.id,
});
await transaction
.update(schema.accounts)
.set({ userId })
.where(eq(schema.accounts.id, user.id));
});
// If account already exists we simply create a token for the user linked to that account
} else {
Expand Down

0 comments on commit 45c343a

Please sign in to comment.