Skip to content

Commit 159378c

Browse files
committed
Merge branch 'main' of github.com:devforth/adminforth-oauth
2 parents 747cba9 + a640f1b commit 159378c

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;
@@ -138,19 +137,21 @@ export default class OAuthPlugin extends AdminForthPlugin {
138137
});
139138
}
140139

141-
const adminUser = {
142-
dbUser: user,
143-
pk: user.id,
144-
username,
145-
};
146-
const toReturn = { allowedLogin: true, error: '' };
147-
await this.adminforth.restApi.processLoginCallbacks(adminUser, toReturn, response, extra);
140+
const adminUser = {
141+
dbUser: user,
142+
pk: user.id,
143+
username,
144+
};
145+
const toReturn = { allowedLogin: true, error: '' };
146+
147+
const rememberMeDays = this.options.authenticationExpireDuration ?? this.adminforth.config.auth.rememberMeDays;
148+
await this.adminforth.restApi.processLoginCallbacks(adminUser, toReturn, response, { ...extra }, rememberMeDays);
148149
if (toReturn.allowedLogin) {
149150
this.adminforth.auth.setAuthCookie({
150151
response,
151152
username,
152153
pk: user.id,
153-
expireInDays: this.options.authenticationExpireDuration ? this.options.authenticationExpireDuration : this.adminforth.config.auth.rememberMeDays
154+
expireInDays: rememberMeDays
154155
});
155156
}
156157
return toReturn;

0 commit comments

Comments
 (0)