|
1 | | -import { AdminForthPlugin, Filters, AdminUser } from "adminforth"; |
| 1 | +import { AdminForthPlugin, Filters, AdminUser, HttpExtra } from "adminforth"; |
2 | 2 | import type { IAdminForth, AdminForthResource } from "adminforth"; |
3 | 3 | import { IHttpServer } from "adminforth"; |
4 | 4 | import { randomUUID } from 'crypto'; |
5 | 5 | import type { OAuth2Adapter } from "adminforth"; |
6 | 6 | import { AdminForthDataTypes } from "adminforth"; |
7 | | -import type { HttpExtra } from './types.js'; |
8 | 7 |
|
9 | 8 | interface OAuthPluginOptions { |
10 | 9 | emailField: string; |
@@ -130,19 +129,21 @@ export default class OAuthPlugin extends AdminForthPlugin { |
130 | 129 | }); |
131 | 130 | } |
132 | 131 |
|
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); |
140 | 141 | if (toReturn.allowedLogin) { |
141 | 142 | this.adminforth.auth.setAuthCookie({ |
142 | 143 | response, |
143 | 144 | username, |
144 | 145 | pk: user.id, |
145 | | - expireInDays: this.options.authenticationExpireDuration ? this.options.authenticationExpireDuration : this.adminforth.config.auth.rememberMeDays |
| 146 | + expireInDays: rememberMeDays |
146 | 147 | }); |
147 | 148 | } |
148 | 149 | return toReturn; |
|
0 commit comments