Skip to content

Commit

Permalink
feat: add secret key on environment variables
Browse files Browse the repository at this point in the history
  • Loading branch information
pauloedurezende committed Jan 10, 2019
1 parent 56af9d0 commit 710d074
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 8 deletions.
1 change: 1 addition & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
DATABASE_USER = 'dbUser.json'
DATABASE_LOCATION = 'dbLocation.json'
PORT = 3000
SECRET_KEY = '49084b52d739f28aaaba047393d54623'
12 changes: 4 additions & 8 deletions src/controllers/auth/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ route.post('/login', middlewareLogin, (req, res) => {

const token = jwt.sign(
{ id: userInfo[0].id, name: userInfo[0].name, email: userInfo[0].email },
'49084b52d739f28aaaba047393d54623',
process.env.SECRET_KEY,
{
expiresIn: 86400
}
Expand Down Expand Up @@ -74,13 +74,9 @@ route.post('/register', middlewareRegister, (req, res) => {

const { id } = newUser;

const token = jwt.sign(
{ id, name, email },
'49084b52d739f28aaaba047393d54623',
{
expiresIn: 86400
}
);
const token = jwt.sign({ id, name, email }, process.env.SECRET_KEY, {
expiresIn: 86400
});

res.json({ auth: true, token });
});
Expand Down

0 comments on commit 710d074

Please sign in to comment.