File tree Expand file tree Collapse file tree 4 files changed +419
-479
lines changed Expand file tree Collapse file tree 4 files changed +419
-479
lines changed Original file line number Diff line number Diff line change 194
194
"@types/terser-webpack-plugin" : " ^5.0.2" ,
195
195
"@types/testing-library__jest-dom" : " ^5.9.5" ,
196
196
"@types/uuid" : " ^8.3.0" ,
197
- "@types/webpack" : " 4.41.25 " ,
197
+ "@types/webpack" : " 4.41.26 " ,
198
198
"@types/webpack-bundle-analyzer" : " ^3.9.0" ,
199
- "@types/webpack-dev-middleware" : " ^3.7.2 " ,
199
+ "@types/webpack-dev-middleware" : " 4.0.0 " ,
200
200
"@types/webpack-env" : " ^1.15.3" ,
201
- "@types/webpack-hot-middleware" : " ^ 2.25.3" ,
201
+ "@types/webpack-hot-middleware" : " 2.25.3" ,
202
202
"@typescript-eslint/eslint-plugin" : " ^4.8.1" ,
203
203
"@typescript-eslint/parser" : " 4.0.1" ,
204
204
"babel-eslint" : " ^10.0.1" ,
Original file line number Diff line number Diff line change @@ -27,8 +27,14 @@ export default function registerCollections(ctx: Payload): void {
27
27
const { maxLoginAttempts, lockTime } = collection . auth ;
28
28
29
29
if ( maxLoginAttempts > 0 ) {
30
+ type LoginSchema = {
31
+ loginAttempts : number
32
+ lockUntil : number
33
+ isLocked : boolean
34
+ } ;
35
+
30
36
// eslint-disable-next-line func-names
31
- schema . methods . incLoginAttempts = function ( cb ) {
37
+ schema . methods . incLoginAttempts = function ( this : mongoose . Document < any > & LoginSchema , cb ) {
32
38
// Expired lock, restart count at 1
33
39
if ( this . lockUntil && this . lockUntil < Date . now ( ) ) {
34
40
return this . updateOne ( {
@@ -37,7 +43,6 @@ export default function registerCollections(ctx: Payload): void {
37
43
} , cb ) ;
38
44
}
39
45
40
- type LoginSchema = { loginAttempts : number ; } ;
41
46
const updates : UpdateQuery < LoginSchema > = { $inc : { loginAttempts : 1 } } ;
42
47
// Lock the account if at max attempts and not already locked
43
48
if ( this . loginAttempts + 1 >= maxLoginAttempts && ! this . isLocked ) {
Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ import path from 'path';
3
3
export const defaults = {
4
4
defaultDepth : 2 ,
5
5
maxDepth : 10 ,
6
+ collections : [ ] ,
6
7
globals : [ ] ,
7
8
cookiePrefix : 'payload' ,
8
9
csrf : [ ] ,
You can’t perform that action at this time.
0 commit comments