Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

updated tests for full coverage #957

Merged
merged 1 commit into from
Oct 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions Server/controllers/authController.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ const registerUser = async (req, res, next) => {
}

const newUser = await req.db.insertUser({ ...req.body }, req.file);

logger.info(successMessages.AUTH_CREATE_USER, {
service: SERVICE_NAME,
userId: newUser._id,
Expand All @@ -78,7 +79,9 @@ const registerUser = async (req, res, next) => {
delete userForToken.avatarImage;

const appSettings = await req.settingsService.getSettings();

const token = issueToken(userForToken, appSettings);

req.emailService
.buildAndSendEmail(
"welcomeEmailTemplate",
Expand All @@ -99,6 +102,7 @@ const registerUser = async (req, res, next) => {
data: { user: newUser, token: token },
});
} catch (error) {
console.log("ERROR", error);
next(handleError(error, SERVICE_NAME, "registerController"));
}
};
Expand Down Expand Up @@ -293,6 +297,8 @@ const requestRecovery = async (req, res, next) => {
msg: successMessages.AUTH_CREATE_RECOVERY_TOKEN,
data: msgId,
});
} else {
throw new Error(errorMessages.FRIENDLY_ERROR);
}
} catch (error) {
next(handleError(error, SERVICE_NAME, "recoveryRequestController"));
Expand Down Expand Up @@ -435,6 +441,7 @@ const getAllUsers = async (req, res) => {
};

module.exports = {
issueToken,
registerUser,
loginUser,
editUser,
Expand Down
Loading