@@ -16,6 +16,7 @@ import cryptoToken from '../../../util/cryptoToken';
1616import generateOTP from '../../../util/generateOTP' ;
1717import { ResetToken } from '../resetToken/resetToken.model' ;
1818import { User } from '../user/user.model' ;
19+ import { USER_STATUS } from '../user/user.constant' ;
1920
2021//login
2122const loginUserFromDB = async ( payload : ILoginData ) => {
@@ -26,15 +27,15 @@ const loginUserFromDB = async (payload: ILoginData) => {
2627 }
2728
2829 //check verified and status
29- if ( ! isExistUser . verified ) {
30+ if ( ! isExistUser . isVerified ) {
3031 throw new ApiError (
3132 StatusCodes . BAD_REQUEST ,
3233 'Please verify your account, then try to login again'
3334 ) ;
3435 }
3536
3637 //check user status
37- if ( isExistUser . status === 'delete' ) {
38+ if ( isExistUser . status !== USER_STATUS . ACTIVE ) {
3839 throw new ApiError (
3940 StatusCodes . BAD_REQUEST ,
4041 '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) => {
113114 let message ;
114115 let data ;
115116
116- if ( ! isExistUser . verified ) {
117+ if ( ! isExistUser . isVerified ) {
117118 await User . findOneAndUpdate (
118119 { _id : isExistUser . _id } ,
119- { verified : true , authentication : { oneTimeCode : null , expireAt : null } }
120+ {
121+ isVerified : true ,
122+ authentication : { oneTimeCode : null , expireAt : null } ,
123+ }
120124 ) ;
121125 message = 'Email verify successfully' ;
122126 } else {
0 commit comments