File tree Expand file tree Collapse file tree 1 file changed +17
-1
lines changed Expand file tree Collapse file tree 1 file changed +17
-1
lines changed Original file line number Diff line number Diff line change @@ -69,7 +69,23 @@ const loginUserFromDB = async (payload: ILoginData) => {
6969const forgetPasswordToDB = async ( email : string ) => {
7070 const isExistUser = await User . isExistUserByEmail ( email ) ;
7171 if ( ! isExistUser ) {
72- throw new ApiError ( StatusCodes . BAD_REQUEST , "User doesn't exist!" ) ;
72+ throw new ApiError ( StatusCodes . BAD_REQUEST , config . node_env === 'development' ? "User doesn't exist!" : "Invalid email" ) ;
73+ }
74+
75+ // check if user is deleted
76+ if ( isExistUser . isDeleted ) {
77+ throw new ApiError (
78+ StatusCodes . BAD_REQUEST ,
79+ 'It looks like your account has been deleted or deactivated.'
80+ ) ;
81+ }
82+
83+ //check user status
84+ if ( isExistUser . status !== USER_STATUS . ACTIVE ) {
85+ throw new ApiError (
86+ StatusCodes . BAD_REQUEST ,
87+ 'It looks like your account has been suspended or deactivated.'
88+ ) ;
7389 }
7490
7591 //send mail
You can’t perform that action at this time.
0 commit comments