@@ -16,6 +16,7 @@ import cryptoToken from '../../../util/cryptoToken';
16
16
import generateOTP from '../../../util/generateOTP' ;
17
17
import { ResetToken } from '../resetToken/resetToken.model' ;
18
18
import { User } from '../user/user.model' ;
19
+ import { USER_STATUS } from '../user/user.constant' ;
19
20
20
21
//login
21
22
const loginUserFromDB = async ( payload : ILoginData ) => {
@@ -26,15 +27,15 @@ const loginUserFromDB = async (payload: ILoginData) => {
26
27
}
27
28
28
29
//check verified and status
29
- if ( ! isExistUser . verified ) {
30
+ if ( ! isExistUser . isVerified ) {
30
31
throw new ApiError (
31
32
StatusCodes . BAD_REQUEST ,
32
33
'Please verify your account, then try to login again'
33
34
) ;
34
35
}
35
36
36
37
//check user status
37
- if ( isExistUser . status === 'delete' ) {
38
+ if ( isExistUser . status !== USER_STATUS . ACTIVE ) {
38
39
throw new ApiError (
39
40
StatusCodes . BAD_REQUEST ,
40
41
'You don’t have permission to access this content.It looks like your account has been deactivated.'
@@ -113,10 +114,13 @@ const verifyEmailToDB = async (payload: IVerifyEmail) => {
113
114
let message ;
114
115
let data ;
115
116
116
- if ( ! isExistUser . verified ) {
117
+ if ( ! isExistUser . isVerified ) {
117
118
await User . findOneAndUpdate (
118
119
{ _id : isExistUser . _id } ,
119
- { verified : true , authentication : { oneTimeCode : null , expireAt : null } }
120
+ {
121
+ isVerified : true ,
122
+ authentication : { oneTimeCode : null , expireAt : null } ,
123
+ }
120
124
) ;
121
125
message = 'Email verify successfully' ;
122
126
} else {
0 commit comments