diff --git a/apps/core-auth0-actions/src/controllers/newuser.ts b/apps/core-auth0-actions/src/controllers/newuser.ts index cc6becd6..5acf251f 100644 --- a/apps/core-auth0-actions/src/controllers/newuser.ts +++ b/apps/core-auth0-actions/src/controllers/newuser.ts @@ -21,6 +21,8 @@ export const addNewUserToDatabaseOnRegister = async (req: Request, res: Response return res.status(500).send('Error creating user'); } + console.log(`User ${userId} with email ${email} created`); + return res.status(200).send(newUser); } catch (err) { console.error(err); diff --git a/apps/core-auth0-actions/src/middlewares/auth.ts b/apps/core-auth0-actions/src/middlewares/auth.ts index 32d72f5b..8afdc020 100644 --- a/apps/core-auth0-actions/src/middlewares/auth.ts +++ b/apps/core-auth0-actions/src/middlewares/auth.ts @@ -4,17 +4,23 @@ export const authorize = (req: Request, res: Response, next: NextFunction) => { const { authorization } = req.headers; if (!authorization) { - return res.status(401).send('Unauthorized'); + return res.status(403).json({ + message: 'No authorization header provided', + }); } const token = authorization.split(' ')[1]; if (!token) { - return res.status(401).send('Unauthorized'); + return res.status(403).json({ + message: 'No token provided', + }); } if (token !== process.env.AUTHORIZATION_SECRET) { - return res.status(401).send('Unauthorized'); + return res.status(401).json({ + message: 'Unauthorized', + }); } next();