Skip to content

Commit

Permalink
Added http codes and returned in json as expected. (#239)
Browse files Browse the repository at this point in the history
  • Loading branch information
igMike-V committed Nov 10, 2023
1 parent 63183a7 commit 1f2064b
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions server/src/modules/auth/controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ const authController = {
getCurrentUser: async (req: Request, res: Response, next: NextFunction) => {
try {
if (req.session.user == null) {
return null;
return res.status(401).json({ user: null, message: 'Unauthorized. User not logged in.' });
}
const { id } = req.session.user;
const user = await authService.getUser(id);
return user;
return res.status(200).json({ user });
} catch (e) {
next(e);
}
Expand Down

0 comments on commit 1f2064b

Please sign in to comment.