({ user, account })
| 439 | }, |
| 440 | // TODO: Ugly |
| 441 | async signIn({ user, account }) { |
| 442 | console.log(`Sign in user: ${user.id}`); |
| 443 | if (!account) { |
| 444 | return true; |
| 445 | } |
| 446 | const identifyAccount = async () => { |
| 447 | Analytics.linkAnalyticsAccount({ |
| 448 | answerOverflowAccountId: user.id, |
| 449 | otherId: account.providerAccountId, |
| 450 | }); |
| 451 | if (account?.provider === 'discord' && account?.access_token) { |
| 452 | const discordAccount = await getDiscordUser({ |
| 453 | accessToken: account.access_token, |
| 454 | }); |
| 455 | Analytics.identifyDiscordAccount(user.id, { |
| 456 | id: discordAccount.id, |
| 457 | username: discordAccount.username, |
| 458 | email: discordAccount.email ?? '', |
| 459 | }); |
| 460 | } |
| 461 | return Analytics.finishAnalyticsCollection(); |
| 462 | }; |
| 463 | const updateAccountInfo = async () => { |
| 464 | const foundAccount = await findAccountByProviderAccountId({ |
| 465 | provider: account.provider, |
| 466 | providerAccountId: account.providerAccountId, |
| 467 | }); |
| 468 | if (!foundAccount) return; |
| 469 | return updateProviderAuthToken(account); |
| 470 | }; |
| 471 | await Promise.all([identifyAccount(), updateAccountInfo()]); |
| 472 | return true; |
| 473 | }, |
| 474 | }, |
| 475 | cookies: { |
| 476 | sessionToken: { |
no test coverage detected