From 1164399501d5b2f6bfcd5dd076d6fbc926ca3f1c Mon Sep 17 00:00:00 2001 From: Emilien Escalle Date: Mon, 19 Nov 2018 02:35:34 +0100 Subject: [PATCH] Update index.d.ts (#30342) * Update index.d.ts Add missing functions "changePassword" & "resetAttempts" Add function returnings promise when a callback is not providen * Update index.d.ts * Update index.d.ts --- types/passport-local-mongoose/index.d.ts | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/types/passport-local-mongoose/index.d.ts b/types/passport-local-mongoose/index.d.ts index 512b68179f..e175dc8d1e 100644 --- a/types/passport-local-mongoose/index.d.ts +++ b/types/passport-local-mongoose/index.d.ts @@ -10,18 +10,33 @@ declare module 'mongoose' { import passportLocal = require('passport-local'); + export interface AuthenticationResult { + user: any; + error: any; + } + // methods export interface PassportLocalDocument extends Document { + setPassword(password: string): Promise; setPassword(password: string, cb: (err: any, res: any) => void): void; - authenticate(password: string, cb: (err: any, res: any, error: any) => void): void; + changePassword(oldPassword: string, newPassword: string): Promise; + changePassword(oldPassword: string, newPassword: string, cb: (err: any, res: any) => void): void; + authenticate(password: string): Promise; + authenticate(password: string, cb: (err: any, user: any, error: any) => void): void; + resetAttempts(): Promise; + resetAttempts(cb: (err: any, res: any) => void): void; } // statics interface PassportLocalModel extends Model { - authenticate(): (username: string, password: string, cb: (err: any, res: T, error: any) => void) => void; + authenticate(): (username: string, password: string) => Promise; + authenticate(): (username: string, password: string, cb: (err: any, user: T | boolean, error: any) => void) => void; serializeUser(): (user: PassportLocalModel, cb: (err: any, id?: any) => void) => void; deserializeUser(): (username: string, cb: (err: any, user?: any) => void) => void; + + register(user: T, password: string): Promise; register(user: T, password: string, cb: (err: any, account: any) => void): void; + findByUsername(username: string, selectHashSaltFields: boolean): Query; findByUsername(username: string, selectHashSaltFields: boolean, cb: (err: any, account: any) => void): any; createStrategy(): passportLocal.Strategy; }