File tree Expand file tree Collapse file tree 2 files changed +12
-3
lines changed Expand file tree Collapse file tree 2 files changed +12
-3
lines changed Original file line number Diff line number Diff line change @@ -25,9 +25,12 @@ export class AuthService {
2525 const match = await bcrypt . compare ( password , user ?. hashedPassword ) ;
2626
2727 if ( ! match ) {
28- throw new UnauthorizedException ( ) ;
28+ throw new UnauthorizedException ( "Password or email doesn't match" ) ;
2929 }
3030
31+ user . lastLogin = new Date ( ) ;
32+ await user . save ( ) ;
33+
3134 await this . mailer . sendTemplateMail ( {
3235 templateType : 'login' ,
3336 recipients : [ email ] ,
Original file line number Diff line number Diff line change @@ -66,7 +66,13 @@ export class UsersService {
6666 }
6767
6868 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+ } ) ;
7076 return await createdUser . save ( ) ;
7177 }
7278
@@ -87,7 +93,7 @@ export class UsersService {
8793 return String ( user . _id ) ;
8894 }
8995
90- async findOneByEmail ( email : string ) : Promise < User | undefined > {
96+ async findOneByEmail ( email : string ) : Promise < UserDocument | undefined > {
9197 return await this . model . findOne ( { email : email } ) ;
9298 }
9399
You can’t perform that action at this time.
0 commit comments