From de2983b84d21329d1575b0f6da87a30b332ef12e Mon Sep 17 00:00:00 2001 From: Alex4386 Date: Thu, 8 Sep 2022 23:13:19 +0000 Subject: [PATCH 1/4] fix: i am an idiot fixed remember feature working other way around --- src/routes/v1/meiling/signin.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/routes/v1/meiling/signin.ts b/src/routes/v1/meiling/signin.ts index 4442a5e5..35ae1496 100644 --- a/src/routes/v1/meiling/signin.ts +++ b/src/routes/v1/meiling/signin.ts @@ -94,6 +94,8 @@ export async function signinHandler(req: FastifyRequest, rep: FastifyReply): Pro const shouldSkip2FA = await Meiling.V1.Session.canSkip2FA(req, user); if (user.useTwoFactor) { if (shouldSkip2FA) { + markToSkip2FA = true; + } else { const twoFactorMethods = await Meiling.V1.User.getAvailableExtendedAuthenticationMethods(user, body.type); if (twoFactorMethods.length > 0) { @@ -110,8 +112,6 @@ export async function signinHandler(req: FastifyRequest, rep: FastifyReply): Pro ); return; } - } else { - markToSkip2FA = true; } } } else if ( From fa21599d4a4089cb608a76b64d970441140d8eff Mon Sep 17 00:00:00 2001 From: Alex4386 Date: Thu, 8 Sep 2022 23:13:41 +0000 Subject: [PATCH 2/4] chore: 0.9.2-snapshot --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 52d640c5..a53fb1cd 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "meiling", - "version": "0.9.1", + "version": "0.9.2-snapshot", "description": "An Opensource Next Generation \"Gatekeeper\" with oAuth2 Authentication Provider and OpenID Connect Server", "main": "dist/", "repository": "https://github.com/meili-NG/meiliNG", From 8d9a1d8efea9e6f5b9cea6569a3c70bc38f1b590 Mon Sep 17 00:00:00 2001 From: Alex4386 Date: Thu, 8 Sep 2022 23:14:03 +0000 Subject: [PATCH 3/4] chore: bump up version to 0.9.2 :arrow_up: --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index a53fb1cd..739fbfce 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "meiling", - "version": "0.9.2-snapshot", + "version": "0.9.2", "description": "An Opensource Next Generation \"Gatekeeper\" with oAuth2 Authentication Provider and OpenID Connect Server", "main": "dist/", "repository": "https://github.com/meili-NG/meiliNG", From 66e5a850468011d86881bb4f5e33fc6de76d1181 Mon Sep 17 00:00:00 2001 From: Alex4386 Date: Thu, 8 Sep 2022 23:19:09 +0000 Subject: [PATCH 4/4] chore: fixed lint --- src/common/meiling/v1/session.ts | 2 +- src/routes/v1/meiling/signin.ts | 50 ++++++++++++++++---------------- 2 files changed, 26 insertions(+), 26 deletions(-) diff --git a/src/common/meiling/v1/session.ts b/src/common/meiling/v1/session.ts index a956452c..e7b771c6 100644 --- a/src/common/meiling/v1/session.ts +++ b/src/common/meiling/v1/session.ts @@ -348,7 +348,7 @@ export async function setSession(req: FastifyRequest, data?: MeilingSession): Pr try { // not async function since we don't need to wait it to complete. Meiling.Identity.User.updateLastAuthenticated(user.id); - } catch (e) { } + } catch (e) {} } } } diff --git a/src/routes/v1/meiling/signin.ts b/src/routes/v1/meiling/signin.ts index 3a631a22..664e5a76 100644 --- a/src/routes/v1/meiling/signin.ts +++ b/src/routes/v1/meiling/signin.ts @@ -311,33 +311,33 @@ export async function signinHandler(req: FastifyRequest, rep: FastifyReply): Pro webauthn: signinMethod === ExtendedAuthMethods.WEBAUTHN ? { - allowCredentials: ( - await getPrismaClient().authentication.findMany({ - where: { - user: { - id: { - in: targetUsers.filter((n) => n !== undefined).map((n) => (n as UserModel).id), + allowCredentials: ( + await getPrismaClient().authentication.findMany({ + where: { + user: { + id: { + in: targetUsers.filter((n) => n !== undefined).map((n) => (n as UserModel).id), + }, }, + method: 'WEBAUTHN', + allowSingleFactor: body.type === SigninType.PASSWORDLESS ? true : undefined, + allowTwoFactor: body.type === SigninType.TWO_FACTOR_AUTH ? true : undefined, }, - method: 'WEBAUTHN', - allowSingleFactor: body.type === SigninType.PASSWORDLESS ? true : undefined, - allowTwoFactor: body.type === SigninType.TWO_FACTOR_AUTH ? true : undefined, - }, - }) - ) - .map((n) => { - const data = n.data as unknown as AuthenticationJSONObject; - if (data.type !== 'WEBAUTHN') { - return; - } - - return { - id: data.data.key.id, - type: 'public-key', - }; - }) - .filter((n) => n !== undefined), - } + }) + ) + .map((n) => { + const data = n.data as unknown as AuthenticationJSONObject; + if (data.type !== 'WEBAUTHN') { + return; + } + + return { + id: data.data.key.id, + type: 'public-key', + }; + }) + .filter((n) => n !== undefined), + } : undefined, };