From b9d080fbe8d9aacf21fa911a0fd56eb071c28f0e Mon Sep 17 00:00:00 2001 From: Egor Makarenko Date: Tue, 17 Nov 2020 17:18:13 +0500 Subject: [PATCH] fix(): Preserve callback.length for strategy constructor --- lib/passport/passport.strategy.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/passport/passport.strategy.ts b/lib/passport/passport.strategy.ts index 8d121145..607ab72c 100644 --- a/lib/passport/passport.strategy.ts +++ b/lib/passport/passport.strategy.ts @@ -25,12 +25,13 @@ export function PassportStrategy = any>( } }; - super(...args, callback); - if (this.validate) { + const validate = new.target.prototype.validate; + if (validate) { Object.defineProperty(callback, 'length', { - value: this.validate.length + 1 + value: validate.length + 1 }); } + super(...args, callback); const passportInstance = this.getPassportInstance(); if (name) {