From b5be5545392af2979ba1fa8a89ad808833c7188d Mon Sep 17 00:00:00 2001 From: Vitalii Date: Mon, 27 Oct 2025 16:22:19 +0200 Subject: [PATCH] fix: pass sessionDuration to processLoginCallbacks --- index.ts | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/index.ts b/index.ts index 5113b14..3126853 100644 --- a/index.ts +++ b/index.ts @@ -1,10 +1,9 @@ -import { AdminForthPlugin, Filters, AdminUser } from "adminforth"; +import { AdminForthPlugin, Filters, AdminUser, HttpExtra } from "adminforth"; import type { IAdminForth, AdminForthResource } from "adminforth"; import { IHttpServer } from "adminforth"; import { randomUUID } from 'crypto'; import type { OAuth2Adapter } from "adminforth"; import { AdminForthDataTypes } from "adminforth"; -import type { HttpExtra } from './types.js'; interface OAuthPluginOptions { emailField: string; @@ -130,19 +129,21 @@ export default class OAuthPlugin extends AdminForthPlugin { }); } - const adminUser = { - dbUser: user, - pk: user.id, - username, - }; - const toReturn = { allowedLogin: true, error: '' }; - await this.adminforth.restApi.processLoginCallbacks(adminUser, toReturn, response, extra); + const adminUser = { + dbUser: user, + pk: user.id, + username, + }; + const toReturn = { allowedLogin: true, error: '' }; + + const rememberMeDays = this.options.authenticationExpireDuration ?? this.adminforth.config.auth.rememberMeDays; + await this.adminforth.restApi.processLoginCallbacks(adminUser, toReturn, response, { ...extra }, rememberMeDays); if (toReturn.allowedLogin) { this.adminforth.auth.setAuthCookie({ response, username, pk: user.id, - expireInDays: this.options.authenticationExpireDuration ? this.options.authenticationExpireDuration : this.adminforth.config.auth.rememberMeDays + expireInDays: rememberMeDays }); } return toReturn;