File tree Expand file tree Collapse file tree 1 file changed +6
-3
lines changed Expand file tree Collapse file tree 1 file changed +6
-3
lines changed Original file line number Diff line number Diff line change @@ -19,10 +19,12 @@ export type UserModel = mongoose.Document & {
19
19
picture : string
20
20
} ,
21
21
22
- comparePassword : ( candidatePassword : string , cb : ( err : any , isMatch : any ) => { } ) => void ,
22
+ comparePassword : comparePasswordFunction ,
23
23
gravatar : ( size : number ) => string
24
24
} ;
25
25
26
+ type comparePasswordFunction = ( candidatePassword : string , cb : ( err : any , isMatch : any ) => { } ) => void ;
27
+
26
28
export type AuthToken = {
27
29
accessToken : string ,
28
30
kind : string
@@ -64,12 +66,13 @@ userSchema.pre("save", function save(next) {
64
66
} ) ;
65
67
} ) ;
66
68
67
- userSchema . methods . comparePassword = function ( candidatePassword : string , cb : ( err : any , isMatch : any ) => { } ) {
69
+ const comparePassword : comparePasswordFunction = function ( candidatePassword , cb ) {
68
70
bcrypt . compare ( candidatePassword , this . password , ( err : mongoose . Error , isMatch : boolean ) => {
69
71
cb ( err , isMatch ) ;
70
72
} ) ;
71
73
} ;
72
74
75
+ userSchema . methods . comparePassword = comparePassword ;
73
76
74
77
/**
75
78
* Helper method for getting user's gravatar.
@@ -87,4 +90,4 @@ userSchema.methods.gravatar = function (size: number) {
87
90
88
91
// export const User: UserType = mongoose.model<UserType>('User', userSchema);
89
92
const User = mongoose . model ( "User" , userSchema ) ;
90
- export default User ;
93
+ export default User ;
You can’t perform that action at this time.
0 commit comments