Skip to content

Commit b5be554

Browse files
committed
fix: pass sessionDuration to processLoginCallbacks
1 parent 359050e commit b5be554

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

index.ts

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
1-
import { AdminForthPlugin, Filters, AdminUser } from "adminforth";
1+
import { AdminForthPlugin, Filters, AdminUser, HttpExtra } from "adminforth";
22
import type { IAdminForth, AdminForthResource } from "adminforth";
33
import { IHttpServer } from "adminforth";
44
import { randomUUID } from 'crypto';
55
import type { OAuth2Adapter } from "adminforth";
66
import { AdminForthDataTypes } from "adminforth";
7-
import type { HttpExtra } from './types.js';
87

98
interface OAuthPluginOptions {
109
emailField: string;
@@ -130,19 +129,21 @@ export default class OAuthPlugin extends AdminForthPlugin {
130129
});
131130
}
132131

133-
const adminUser = {
134-
dbUser: user,
135-
pk: user.id,
136-
username,
137-
};
138-
const toReturn = { allowedLogin: true, error: '' };
139-
await this.adminforth.restApi.processLoginCallbacks(adminUser, toReturn, response, extra);
132+
const adminUser = {
133+
dbUser: user,
134+
pk: user.id,
135+
username,
136+
};
137+
const toReturn = { allowedLogin: true, error: '' };
138+
139+
const rememberMeDays = this.options.authenticationExpireDuration ?? this.adminforth.config.auth.rememberMeDays;
140+
await this.adminforth.restApi.processLoginCallbacks(adminUser, toReturn, response, { ...extra }, rememberMeDays);
140141
if (toReturn.allowedLogin) {
141142
this.adminforth.auth.setAuthCookie({
142143
response,
143144
username,
144145
pk: user.id,
145-
expireInDays: this.options.authenticationExpireDuration ? this.options.authenticationExpireDuration : this.adminforth.config.auth.rememberMeDays
146+
expireInDays: rememberMeDays
146147
});
147148
}
148149
return toReturn;

0 commit comments

Comments
 (0)