@@ -34,6 +34,7 @@ app.post('/register', (req, res) => {
3434 name : req . body . name ,
3535 email : req . body . email ,
3636 password : req . body . password
37+ // In a production app, you'll want to encrypt the password
3738 }
3839
3940 const data = JSON . stringify ( user , null , 2 )
@@ -47,12 +48,12 @@ app.post('/register', (req, res) => {
4748 console . log ( err + data )
4849 } else {
4950 const token = jwt . sign ( { user } , 'the_secret_key' )
51+ // In a production app, you'll want the secret key to be an environment variable
5052 res . json ( {
5153 token,
5254 email : user . email ,
5355 name : user . name
5456 } )
55- console . log ( `Added ${ data } to user.json` )
5657 }
5758 } )
5859 }
@@ -70,6 +71,7 @@ app.post('/login', (req, res) => {
7071 req . body . password === userInfo . password
7172 ) {
7273 const token = jwt . sign ( { userInfo } , 'the_secret_key' )
74+ // In a production app, you'll want the secret key to be an environment variable
7375 res . json ( {
7476 token,
7577 email : userInfo . email ,
@@ -80,8 +82,8 @@ app.post('/login', (req, res) => {
8082 }
8183} )
8284
83- //MIDDLEWARE
84- function verifyToken ( req , res , next ) {
85+ // MIDDLEWARE
86+ function verifyToken ( req , res , next ) {
8587 const bearerHeader = req . headers [ 'authorization' ]
8688
8789 if ( typeof bearerHeader !== 'undefined' ) {
0 commit comments