Skip to content

Commit 7942e2e

Browse files
committed
added comments to server.js
1 parent 6effd1a commit 7942e2e

3 files changed

Lines changed: 11 additions & 9 deletions

File tree

db/user.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"name": "Mary Beth",
3-
"email": "mary@gmail.com",
2+
"name": "John Smith",
3+
"email": "john@gmail.com",
44
"password": "pass123"
55
}

server.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -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') {

src/views/Authenticate.vue

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<template>
22
<div>
3-
<component :is="loginOrRegister"/>
3+
<component :is="loginOrRegister" />
44
<a
55
v-show="isNewUser"
66
class="auth-link"
@@ -21,15 +21,15 @@ import LoginUser from '../components/LoginUser'
2121
export default {
2222
components: { RegisterUser, LoginUser },
2323
computed: {
24-
isNewUser() {
24+
isNewUser () {
2525
return this.$store.state.isNewUser
2626
},
27-
loginOrRegister() {
27+
loginOrRegister () {
2828
return this.isNewUser ? 'LoginUser' : 'RegisterUser'
2929
}
3030
},
3131
methods: {
32-
toggleComponent() {
32+
toggleComponent () {
3333
this.$store.dispatch('isNewUser', !this.isNewUser)
3434
}
3535
}

0 commit comments

Comments
 (0)