Skip to content

Commit

Permalink
Fixed linting
Browse files Browse the repository at this point in the history
  • Loading branch information
J12934 committed Feb 20, 2019
1 parent 094c3e7 commit 35bbc74
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 17 deletions.
4 changes: 2 additions & 2 deletions routes/2fa.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ function verify () {
}

const user = await models.User.findByPk(userId)

const isValid = otplib.authenticator.check(totpToken, user.totpSecret)

const plainUser = utils.queryResultToJson(user)

if (isValid) {
Expand Down
29 changes: 14 additions & 15 deletions test/api/2faSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,26 +19,25 @@ describe('/rest/2fa/verify', () => {

const totpToken = otplib.authenticator.generate('IFTXE3SPOEYVURT2MRYGI52TKJ4HC3KH')


await frisby.post(REST_URL + '/2fa/verify', {
headers: jsonHeader,
body: {
tmpToken: tmpTokenJ12934,
totpToken
}
})
.expect('status', 200)
.expect('header', 'content-type', /application\/json/)
.expect('jsonTypes', 'authentication', {
token: Joi.string(),
umail: Joi.string(),
bid: Joi.number()
})
.expect('json', 'authentication', {
umail: `J12934@${config.get('application.domain')}`
})
.expect('status', 200)
.expect('header', 'content-type', /application\/json/)
.expect('jsonTypes', 'authentication', {
token: Joi.string(),
umail: Joi.string(),
bid: Joi.number()
})
.expect('json', 'authentication', {
umail: `J12934@${config.get('application.domain')}`
})
})

it('POST should fail if a invalid totp token is used', async () => {
const tmpTokenJ12934 = insecurity.authorize({
userId: 9,
Expand All @@ -54,9 +53,9 @@ describe('/rest/2fa/verify', () => {
totpToken
}
})
.expect('status', 401)
.expect('status', 401)
})

it('POST should fail if a unsigned tmp token is used', async () => {
const tmpTokenJ12934 = jwt.sign({
userId: 9,
Expand All @@ -72,6 +71,6 @@ describe('/rest/2fa/verify', () => {
totpToken
}
})
.expect('status', 401)
.expect('status', 401)
})
})

0 comments on commit 35bbc74

Please sign in to comment.