Skip to content

Commit 410f4f3

Browse files
committed
inhance: forget password api
1 parent 2326f88 commit 410f4f3

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

src/app/modules/auth/auth.service.ts

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,23 @@ const loginUserFromDB = async (payload: ILoginData) => {
6969
const 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

0 commit comments

Comments
 (0)