Skip to content

Commit ce2e83a

Browse files
committed
exit getUser if user session doesn't exist
1 parent 3ee8258 commit ce2e83a

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

client/modules/User/actions.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,11 @@ export function getUser() {
9696
const response = await apiClient.get('/session');
9797
const { data } = response;
9898

99+
// If data.user is null, undefined, or not present
100+
if (!data?.user) {
101+
return;
102+
}
103+
99104
dispatch(authenticateUser(data));
100105
dispatch({
101106
type: ActionTypes.SET_PREFERENCES,

server/controllers/session.controller.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ export function createSession(req, res, next) {
2525

2626
export function getSession(req, res) {
2727
if (!req.user) {
28-
return res.status(200).send({ message: 'Session does not exist.' });
28+
return res.status(200).send({ user: null });
2929
}
3030
if (req.user.banned) {
3131
return res.status(403).send({ message: 'Forbidden: User is banned.' });

0 commit comments

Comments
 (0)