Skip to content

Commit 6d092d0

Browse files
committed
fix: switch from urlEncoded to json data
1 parent 6efd29d commit 6d092d0

File tree

2 files changed

+2
-5
lines changed

2 files changed

+2
-5
lines changed

auth/router.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ const createAuthToken = function(user) {
1616
};
1717

1818
const localAuth = passport.authenticate('local', {session: false});
19-
const formParser = bodyParser.urlencoded({ extended: true });
19+
router.use(bodyParser.json());
2020
// The user provides a username and password to login
21-
router.post('/login', formParser, localAuth, (req, res) => {
21+
router.post('/login', localAuth, (req, res) => {
2222
const authToken = createAuthToken(req.user.apiRepr());
2323
res.json({authToken});
2424
});

test/test-auth.js

-3
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,6 @@ describe('Auth endpoints', function () {
6565
return chai
6666
.request(app)
6767
.post('/api/auth/login')
68-
.type('form')
6968
.send({ username: 'wrongUsername', password })
7069
.then(() =>
7170
expect.fail(null, null, 'Request should not succeed')
@@ -83,7 +82,6 @@ describe('Auth endpoints', function () {
8382
return chai
8483
.request(app)
8584
.post('/api/auth/login')
86-
.type('form')
8785
.send({ username, password: 'wrongPassword' })
8886
.then(() =>
8987
expect.fail(null, null, 'Request should not succeed')
@@ -101,7 +99,6 @@ describe('Auth endpoints', function () {
10199
return chai
102100
.request(app)
103101
.post('/api/auth/login')
104-
.type('form')
105102
.send({ username, password })
106103
.then(res => {
107104
expect(res).to.have.status(200);

0 commit comments

Comments
 (0)