Skip to content

Commit

Permalink
fix: userId
Browse files Browse the repository at this point in the history
Signed-off-by: Innei <[email protected]>
  • Loading branch information
Innei committed Nov 26, 2024
1 parent 5c936b5 commit 2143a8c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
2 changes: 2 additions & 0 deletions apps/core/src/modules/auth/auth.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,8 @@ export class AuthController {
...session.user,
...account,
...omit(session, ['session', 'user']),

id: session?.user?.id ?? session.providerAccountId,
}
}

Expand Down
8 changes: 8 additions & 0 deletions apps/core/src/modules/auth/auth.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -209,13 +209,20 @@ export class AuthService {
{
projection: {
providerAccountId: 1,
// authjs field
provider: 1,
providerId: 1,
type: 1,
userId: 1,
},
},
)

// transformer
if (account?.providerId && !account.provider) {
account.provider = account.providerId
}

if (account?.userId) {
const user = await this.databaseService.db
.collection(AUTH_JS_USER_COLLECTION)
Expand All @@ -230,6 +237,7 @@ export class AuthService {
image: 1,
isOwner: 1,
handle: 1,
_id: 1,
},
},
)
Expand Down

0 comments on commit 2143a8c

Please sign in to comment.