File tree 2 files changed +12
-3
lines changed
2 files changed +12
-3
lines changed Original file line number Diff line number Diff line change @@ -25,9 +25,12 @@ export class AuthService {
25
25
const match = await bcrypt . compare ( password , user ?. hashedPassword ) ;
26
26
27
27
if ( ! match ) {
28
- throw new UnauthorizedException ( ) ;
28
+ throw new UnauthorizedException ( "Password or email doesn't match" ) ;
29
29
}
30
30
31
+ user . lastLogin = new Date ( ) ;
32
+ await user . save ( ) ;
33
+
31
34
await this . mailer . sendTemplateMail ( {
32
35
templateType : 'login' ,
33
36
recipients : [ email ] ,
Original file line number Diff line number Diff line change @@ -66,7 +66,13 @@ export class UsersService {
66
66
}
67
67
68
68
async create ( createUserDto : CreateUserDto ) : Promise < User > {
69
- const createdUser = new this . model ( createUserDto ) ;
69
+ const now = new Date ( ) ;
70
+
71
+ const createdUser = new this . model ( {
72
+ ...createUserDto ,
73
+ lastLogin : now ,
74
+ joined : now ,
75
+ } ) ;
70
76
return await createdUser . save ( ) ;
71
77
}
72
78
@@ -87,7 +93,7 @@ export class UsersService {
87
93
return String ( user . _id ) ;
88
94
}
89
95
90
- async findOneByEmail ( email : string ) : Promise < User | undefined > {
96
+ async findOneByEmail ( email : string ) : Promise < UserDocument | undefined > {
91
97
return await this . model . findOne ( { email : email } ) ;
92
98
}
93
99
You can’t perform that action at this time.
0 commit comments