From 4bf21a206d8cc56d6941b08854af12ce910b0792 Mon Sep 17 00:00:00 2001 From: prostgles Date: Mon, 25 Nov 2024 19:08:12 +0200 Subject: [PATCH] fix auth session --- lib/Auth/AuthTypes.ts | 4 ++-- lib/Auth/setAuthProviders.ts | 5 +++-- package-lock.json | 4 ++-- package.json | 2 +- tests/server/package-lock.json | 2 +- 5 files changed, 9 insertions(+), 8 deletions(-) diff --git a/lib/Auth/AuthTypes.ts b/lib/Auth/AuthTypes.ts index b2ec49b0..0dfeb978 100644 --- a/lib/Auth/AuthTypes.ts +++ b/lib/Auth/AuthTypes.ts @@ -124,11 +124,11 @@ export type AuthRegistrationConfig = RegistrationProviders & { * Used to stop abuse */ onProviderLoginStart: (data: { provider: IdentityProvider; req: ExpressReq, res: ExpressRes}, client: LoginClientInfo) => Promise<{ error: string; } | { ok: true; }>; - + /** * Used to identify abuse */ - onProviderLoginFail: (data: { provider: IdentityProvider; error: any, req: ExpressReq, res: ExpressRes}) => void | Promise; + onProviderLoginFail: (data: { provider: IdentityProvider; error: any, req: ExpressReq, res: ExpressRes}, client: LoginClientInfo) => void | Promise; }; export type SessionUser = { diff --git a/lib/Auth/setAuthProviders.ts b/lib/Auth/setAuthProviders.ts index 84b7f4fd..3d0f906f 100644 --- a/lib/Auth/setAuthProviders.ts +++ b/lib/Auth/setAuthProviders.ts @@ -90,7 +90,8 @@ export function setAuthProviders (this: AuthHandler, { registrations, app }: Req callbackPath, async (req, res) => { try { - const startCheck = await onProviderLoginStart({ provider: providerName, req, res }, getLoginClientInfo({ httpReq: req })); + const clientInfo = getLoginClientInfo({ httpReq: req }); + const startCheck = await onProviderLoginStart({ provider: providerName, req, res }, clientInfo); if("error" in startCheck){ res.status(500).json({ error: startCheck.error }); return; @@ -104,7 +105,7 @@ export function setAuthProviders (this: AuthHandler, { registrations, app }: Req }, async (error: any, _profile: any, authInfo: any) => { if(error){ - await onProviderLoginFail({ provider: providerName, error, req, res }); + await onProviderLoginFail({ provider: providerName, error, req, res }, clientInfo); res.status(500).json({ error: "Failed to login with provider", }); diff --git a/package-lock.json b/package-lock.json index 41a7b22d..6a3e1544 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "prostgles-server", - "version": "4.2.148", + "version": "4.2.149", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "prostgles-server", - "version": "4.2.148", + "version": "4.2.149", "license": "MIT", "dependencies": { "body-parser": "^1.20.3", diff --git a/package.json b/package.json index d1394a54..78b4d857 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "prostgles-server", - "version": "4.2.148", + "version": "4.2.149", "description": "", "main": "dist/index.js", "types": "dist/index.d.ts", diff --git a/tests/server/package-lock.json b/tests/server/package-lock.json index f918673a..c86b2b94 100644 --- a/tests/server/package-lock.json +++ b/tests/server/package-lock.json @@ -21,7 +21,7 @@ }, "../..": { "name": "prostgles-server", - "version": "4.2.148", + "version": "4.2.149", "license": "MIT", "dependencies": { "body-parser": "^1.20.3",