Skip to content
This repository has been archived by the owner on Jul 17, 2022. It is now read-only.

Commit

Permalink
fix: use token instead of code
Browse files Browse the repository at this point in the history
  • Loading branch information
coderbyheart committed Sep 3, 2021
1 parent 050621d commit 2c39069
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/routes/password/new.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const newPasswordUsingTokenInput = Type.Object(
{
email: emailInput,
newPassword: passwordInput,
code: Type.String({ pattern: '^[0-9]{6}$' }),
token: Type.String({ pattern: '^[0-9]{6}$' }),
},
{ additionalProperties: false },
)
Expand All @@ -39,7 +39,7 @@ const setNewPasswordUsingTokenAndEmail =

const token = await VerificationToken.findByUserAccountAndToken(
user,
valid.value.code,
valid.value.token,
)
if (token === undefined) return response.status(401).end()

Expand Down
5 changes: 3 additions & 2 deletions src/tests/authentication.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ describe('User account API', () => {
userAccountId: (await UserAccount.findOneByEmail(email))?.id,
},
})
expect(token).not.toBeUndefined()
expect(token).toBeDefined()
return r
.post('/register/confirm')
.set('Content-type', 'application/json; charset=utf-8')
Expand Down Expand Up @@ -264,7 +264,8 @@ describe('User account API', () => {
userAccountId: (await UserAccount.findOneByEmail(email))?.id,
},
})
expect(t).not.toBeUndefined()
expect(t).toBeDefined()
expect(t!.token).toBeDefined()
token = t!.token
})
it('should reset the password using the token', () =>
Expand Down

0 comments on commit 2c39069

Please sign in to comment.