Skip to content

Commit

Permalink
fix auth session
Browse files Browse the repository at this point in the history
  • Loading branch information
prostgles committed Nov 25, 2024
1 parent c33f767 commit 4bf21a2
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 8 deletions.
4 changes: 2 additions & 2 deletions lib/Auth/AuthTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<void>;
onProviderLoginFail: (data: { provider: IdentityProvider; error: any, req: ExpressReq, res: ExpressRes}, client: LoginClientInfo) => void | Promise<void>;
};

export type SessionUser<ServerUser extends UserLike = UserLike, ClientUser extends UserLike = UserLike> = {
Expand Down
5 changes: 3 additions & 2 deletions lib/Auth/setAuthProviders.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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",
});
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
2 changes: 1 addition & 1 deletion tests/server/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 4bf21a2

Please sign in to comment.