Skip to content

Commit

Permalink
Merge pull request #957 from bluewave-labs/fix/be/auth-controller-tes…
Browse files Browse the repository at this point in the history
…t-coverage

updated tests for full coverage
  • Loading branch information
ajhollid authored Oct 14, 2024
2 parents e3c0d23 + 7523897 commit 3c400d3
Show file tree
Hide file tree
Showing 2 changed files with 265 additions and 65 deletions.
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

0 comments on commit 3c400d3

Please sign in to comment.