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
This commit is contained in:
Emilien Escalle
2018-11-18 17:35:34 -08:00
committed by Pranav Senthilnathan
parent 53947a7d00
commit 1164399501
+17 -2
View File
@@ -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<PassportLocalDocument>;
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<PassportLocalDocument>;
changePassword(oldPassword: string, newPassword: string, cb: (err: any, res: any) => void): void;
authenticate(password: string): Promise<AuthenticationResult>;
authenticate(password: string, cb: (err: any, user: any, error: any) => void): void;
resetAttempts(): Promise<PassportLocalDocument>;
resetAttempts(cb: (err: any, res: any) => void): void;
}
// statics
interface PassportLocalModel<T extends Document> extends Model<T> {
authenticate(): (username: string, password: string, cb: (err: any, res: T, error: any) => void) => void;
authenticate(): (username: string, password: string) => Promise<AuthenticationResult>;
authenticate(): (username: string, password: string, cb: (err: any, user: T | boolean, error: any) => void) => void;
serializeUser(): (user: PassportLocalModel<T>, cb: (err: any, id?: any) => void) => void;
deserializeUser(): (username: string, cb: (err: any, user?: any) => void) => void;
register(user: T, password: string): Promise<T>;
register(user: T, password: string, cb: (err: any, account: any) => void): void;
findByUsername(username: string, selectHashSaltFields: boolean): Query<T>;
findByUsername(username: string, selectHashSaltFields: boolean, cb: (err: any, account: any) => void): any;
createStrategy(): passportLocal.Strategy;
}