Skip to content

Commit a118c5c

Browse files
authored
Merge pull request #18 from Wayfinder-CS262-2020/auth
Fix for timed out response
2 parents 8fc950d + b7a973d commit a118c5c

File tree

3 files changed

+10
-6
lines changed

3 files changed

+10
-6
lines changed

.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,7 @@ npm-debug.log
99

1010
# Docker
1111
Dockerfile
12-
docker-compose.yml
12+
docker-compose.yml
13+
14+
# HTTP Test file
15+
test.http

app.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,26 +105,27 @@ function auth(req, res, next) {
105105
const email = req.body.email;
106106
const username = req.body.email.split('@')[0]
107107
const password = req.body.password;
108-
console.log(req.body)
109108
if (email && password) {
110109
db.oneOrNone(`SELECT pass FROM accounts WHERE email = $1`, [
111110
email,
112111
]) // Request the hashed password from the db
113112
.then((data) => {
114113
if (data) {
115-
console.log(data.pass)
116114

117115
if (bcrypt.compareSync(password, data.pass)) { // compare the hashed password with the login password
118116
const accessToken = jwt.sign({ username: username }, accessTokenSecret) // create a signed jwt
117+
console.log("login successful")
119118
res.json(
120119
{
121120
accessToken // respond with the token
122121
}
123122
);
124123
} else {
125124

126-
res.send('Invalid Login Details!')
125+
res.send('Invalid Login Details!') // Password incorrect
127126
}
127+
} else {
128+
res.send('Invalid Login Details!') // Email incorrect
128129
}
129130
})
130131
.catch((err) => {

test.http

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@ POST https://wayfinder-de-auth-gzffdob0fkfq.herokuapp.com/auth/login
22
Content-Type: application/json
33

44
{
5-
"email": "qwerty12@calvin.edu",
6-
"password" : "strongpassword"
5+
"email": "qwer1212@students.calvin.edu",
6+
"password" : "strongpassworawef"
77
}

0 commit comments

Comments
 (0)