File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11import AdminJS from "adminjs" ;
22import { Router } from "express" ;
33import {
4+ AuthContext ,
45 AuthenticationMaxRetriesOptions ,
56 AuthenticationOptions ,
67} from "../types" ;
@@ -89,7 +90,8 @@ export const withLogin = (
8990 email : string ;
9091 password : string ;
9192 } ;
92- const adminUser = await auth . authenticate ( email , password ) ;
93+ const context : AuthContext = { req, res } ;
94+ const adminUser = await auth . authenticate ( email , password , context ) ;
9395 if ( adminUser ) {
9496 req . session . adminUser = adminUser ;
9597 req . session . save ( ( err ) => {
Original file line number Diff line number Diff line change 1+ import { Request , Response } from "express" ;
12export type FormidableOptions = {
23 encoding ?: string ;
34 uploadDir ?: string ;
@@ -10,6 +11,17 @@ export type FormidableOptions = {
1011 multiples ?: boolean ;
1112} ;
1213
14+ export type AuthenticationContext = {
15+ /**
16+ * @description Authentication request object
17+ */
18+ req : Request ;
19+ /**
20+ * @description Authentication response object
21+ */
22+ res : Response ;
23+ } ;
24+
1325export type AuthenticationMaxRetriesOptions = {
1426 /**
1527 * @description Count of retries
@@ -24,7 +36,11 @@ export type AuthenticationMaxRetriesOptions = {
2436export type AuthenticationOptions = {
2537 cookiePassword : string ;
2638 cookieName ?: string ;
27- authenticate : ( email : string , password : string ) => unknown | null ;
39+ authenticate : (
40+ email : string ,
41+ password : string ,
42+ context ?: AuthenticationContext
43+ ) => unknown | null ;
2844 /**
2945 * @description Maximum number of authorization attempts (if number - per minute)
3046 */
You can’t perform that action at this time.
0 commit comments