Skip to content

Commit

Permalink
fix: send refresh token after register
Browse files Browse the repository at this point in the history
  • Loading branch information
TimmePfeife committed Oct 24, 2019
1 parent b438081 commit 16673fe
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/routes/bookbox.route.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Router.get('/', async (req, res) => {

Router.post('/', Auth, Upload.single('file'), Validation('bookbox'), async (req, res) => {
try {
if (!Images.checkFileType(req.file)) {
if (req.file && !Images.checkFileType(req.file)) {
res.sendStatus(HttpStatus.BAD_REQUEST);
return;
}
Expand Down
6 changes: 2 additions & 4 deletions src/routes/users.route.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ Router.post('/', Limiter(Config.limits.critical), Validation('users'), async (re
return;
}

user.refreshToken = await Users.createRefreshToken(user.id, '1 day');

user.token = Users.createJwt({
id: user.id,
role: role.name
Expand All @@ -40,10 +42,6 @@ Router.post('/', Limiter(Config.limits.critical), Validation('users'), async (re
return;
}

if (parseInt(e.code) === 23505) {
res.sendStatus(HttpStatus.CONFLICT);
return;
}
res.sendStatus(HttpStatus.INTERNAL_SERVER_ERROR);
}
});
Expand Down

0 comments on commit 16673fe

Please sign in to comment.