Skip to content

Commit

Permalink
feat: Allow specifying callback arity
Browse files Browse the repository at this point in the history
  • Loading branch information
xenia-lang committed Feb 20, 2023
1 parent a6d4c35 commit 4408774
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions lib/passport/passport.strategy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ import { Type } from '../interfaces';

export function PassportStrategy<T extends Type<any> = any>(
Strategy: T,
name?: string | undefined
name?: string | undefined,
callbackArity?: true | Number
): {
new (...args): InstanceType<T>;
} {
Expand All @@ -24,17 +25,17 @@ export function PassportStrategy<T extends Type<any> = any>(
done(err, null);
}
};
/**
* Commented out due to the regression it introduced
* Read more here: https://github.com/nestjs/passport/issues/446

if (callbackArity !== undefined) {
const validate = new.target?.prototype?.validate;
const arity =
callbackArity === true ? validate.length + 1 : callbackArity;
if (validate) {
Object.defineProperty(callback, 'length', {
value: validate.length + 1
value: arity
});
}
*/
}
super(...args, callback);

const passportInstance = this.getPassportInstance();
Expand Down

0 comments on commit 4408774

Please sign in to comment.