Skip to content

Commit

Permalink
feat(auth): add type & message for notification in sign in sign up ✨
Browse files Browse the repository at this point in the history
  • Loading branch information
PierreBrisorgueil committed Mar 5, 2020
1 parent a601079 commit 4c7147d
Showing 1 changed file with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ exports.signup = async (req, res) => {
const token = jwt.sign({ userId: user.id }, config.jwt.secret, { expiresIn: config.jwt.expiresIn });
return res.status(200)
.cookie('TOKEN', token, { httpOnly: true })
.json({ user, tokenExpiresIn: Date.now() + (config.jwt.expiresIn * 1000) });
.json({
user, tokenExpiresIn: Date.now() + (config.jwt.expiresIn * 1000), type: 'sucess', message: 'Sign up',
});
} catch (err) {
responses.error(res, 422, 'Unprocessable Entity', errors.getMessage(err))(err);
}
Expand All @@ -45,7 +47,9 @@ exports.signin = async (req, res) => {
const token = jwt.sign({ userId: user.id }, configuration.jwt.secret, { expiresIn: config.jwt.expiresIn });
return res.status(200)
.cookie('TOKEN', token, { httpOnly: true })
.json({ user, tokenExpiresIn: Date.now() + (config.jwt.expiresIn * 1000) });
.json({
user, tokenExpiresIn: Date.now() + (config.jwt.expiresIn * 1000), type: 'sucess', message: 'Sign up',
});
};

/**
Expand Down

0 comments on commit 4c7147d

Please sign in to comment.