Skip to content

Commit 19d1030

Browse files
committed
fix: oauth profile for github
Signed-off-by: Innei <i@innei.in>
1 parent d169d51 commit 19d1030

File tree

3 files changed

+19
-9
lines changed

3 files changed

+19
-9
lines changed

apps/core/src/modules/auth/auth.config.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,7 @@ export const authConfig: ServerAuthConfig = {
2222
},
2323
},
2424
providers: [],
25-
experimental: {
26-
enableWebAuthn: true,
27-
},
25+
2826
adapter: MongoDBAdapter(
2927
getDatabaseConnection().then((c) => c.getClient()),
3028
{

apps/core/src/modules/auth/auth.middleware.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,18 @@ export class AuthMiddleware implements NestMiddleware, OnModuleInit {
4646
const provider = github({
4747
clientId: mergedConfig.clientId,
4848
clientSecret: mergedConfig.clientSecret,
49+
// allowDangerousEmailAccountLinking: true,
50+
profile(profile) {
51+
return {
52+
id: profile.id.toString(),
53+
54+
email: profile.email,
55+
name: profile.name || profile.login,
56+
handle: profile.login,
57+
image: profile.avatar_url,
58+
isOwner: false,
59+
}
60+
},
4961
})
5062
providers.push(provider)
5163
}

apps/core/src/utils/database.util.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,13 @@ import {
1313
} from '~/constants/db.constant'
1414
import { logger } from '~/global/consola.global'
1515

16-
let databaseConnection: mongoose.Connection | null = null
16+
let databaseConnectionPromise: Promise<mongoose.Connection> | null = null
1717

1818
mongoose.set('strictQuery', true)
1919

20-
export const getDatabaseConnection = async () => {
21-
if (databaseConnection) {
22-
return databaseConnection
20+
export const getDatabaseConnection = () => {
21+
if (databaseConnectionPromise) {
22+
return databaseConnectionPromise
2323
}
2424
let reconnectionTask: NodeJS.Timeout | null = null
2525
const RECONNECT_INTERVAL = 6000
@@ -59,9 +59,9 @@ export const getDatabaseConnection = async () => {
5959
mongoose.disconnect()
6060
})
6161

62-
databaseConnection = await connection()
62+
databaseConnectionPromise = connection()
6363

64-
return databaseConnection
64+
return databaseConnectionPromise
6565
}
6666

6767
export const normalizeRefType = (type: keyof typeof CollectionRefTypes) => {

0 commit comments

Comments
 (0)