File tree Expand file tree Collapse file tree 2 files changed +20
-2
lines changed Expand file tree Collapse file tree 2 files changed +20
-2
lines changed Original file line number Diff line number Diff line change 1
1
import AdminJS from "adminjs" ;
2
2
import { Router } from "express" ;
3
3
import {
4
+ AuthContext ,
4
5
AuthenticationMaxRetriesOptions ,
5
6
AuthenticationOptions ,
6
7
} from "../types" ;
@@ -89,7 +90,8 @@ export const withLogin = (
89
90
email : string ;
90
91
password : string ;
91
92
} ;
92
- const adminUser = await auth . authenticate ( email , password ) ;
93
+ const context : AuthContext = { req, res } ;
94
+ const adminUser = await auth . authenticate ( email , password , context ) ;
93
95
if ( adminUser ) {
94
96
req . session . adminUser = adminUser ;
95
97
req . session . save ( ( err ) => {
Original file line number Diff line number Diff line change
1
+ import { Request , Response } from "express" ;
1
2
export type FormidableOptions = {
2
3
encoding ?: string ;
3
4
uploadDir ?: string ;
@@ -10,6 +11,17 @@ export type FormidableOptions = {
10
11
multiples ?: boolean ;
11
12
} ;
12
13
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
+
13
25
export type AuthenticationMaxRetriesOptions = {
14
26
/**
15
27
* @description Count of retries
@@ -24,7 +36,11 @@ export type AuthenticationMaxRetriesOptions = {
24
36
export type AuthenticationOptions = {
25
37
cookiePassword : string ;
26
38
cookieName ?: string ;
27
- authenticate : ( email : string , password : string ) => unknown | null ;
39
+ authenticate : (
40
+ email : string ,
41
+ password : string ,
42
+ context ?: AuthenticationContext
43
+ ) => unknown | null ;
28
44
/**
29
45
* @description Maximum number of authorization attempts (if number - per minute)
30
46
*/
You can’t perform that action at this time.
0 commit comments