|
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; |
@@ -138,19 +137,21 @@ export default class OAuthPlugin extends AdminForthPlugin { |
138 | 137 | }); |
139 | 138 | } |
140 | 139 |
|
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); |
148 | 149 | if (toReturn.allowedLogin) { |
149 | 150 | this.adminforth.auth.setAuthCookie({ |
150 | 151 | response, |
151 | 152 | username, |
152 | 153 | pk: user.id, |
153 | | - expireInDays: this.options.authenticationExpireDuration ? this.options.authenticationExpireDuration : this.adminforth.config.auth.rememberMeDays |
| 154 | + expireInDays: rememberMeDays |
154 | 155 | }); |
155 | 156 | } |
156 | 157 | return toReturn; |
|
0 commit comments