Skip to content

Commit

Permalink
CHE-41 Adjustment made to route to use req.query for the token string
Browse files Browse the repository at this point in the history
  • Loading branch information
brok3turtl3 committed Mar 26, 2024
1 parent cf2d108 commit 3ca3d5d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 3 additions & 1 deletion server/controllers/userController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const registerUser = async (
next: NextFunction
) => {
const { firstName, lastName, email, password } = req.body;
const { token } = req.params;
const { token } = req.query;

try {
const isValidEmail = email.match(/[\w\d\.]+@[a-z]+\.[\w]+$/gim);
Expand All @@ -27,6 +27,8 @@ const registerUser = async (
tokenExpiry: { $gt: new Date() },
isRegistered: false,
});

//TODO Needs better error handling - this can trigger with situaions other than bad or missing token
if (!invitation) {
return res
.status(400)
Expand Down
2 changes: 1 addition & 1 deletion server/routes/userRoutes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
const router = express.Router();

router.post("/login", authUser);
router.post("/register/:token", registerUser);
router.post("/register", registerUser);
router.delete("/:email", deleteUserByEmail);
router.get("/:userId", getUserById);

Expand Down

0 comments on commit 3ca3d5d

Please sign in to comment.