New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: validate account.tokens.type #36
Conversation
@gr2m Greg, I think it is weird. I had a pull request about 'test: sessions.remove..', but it still remains. I'm afraid this pull request goes wrong. |
I’ve rebased your pull request on latest changes in master and forced-pushed the changes to your |
if (typeof tokenOptions.type !== 'string' || | ||
!validPattern.test(tokenOptions.type)) { | ||
return Promise.reject(errors.TOKEN_TYPE_INVALID) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you move this code into a separate file like /lib/utils/is-valid-token-type.js
and then do if (!isValidTokenType(tokenOptions.type)) {
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm fixing it!
|
||
module.exports.TOKEN_TYPE_INVALID = hoodieError({ | ||
name: 'Bad Request', | ||
message: 'Type must be a string of lowercase characters, numbers, -, or _, and must begin with a character.', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we change the error message to: Token type must consist of lowercase letters (a-z), digits (0-9), _ and - only. Must begin with a letter
. No .
at the end
t.is(error.status, 400) | ||
t.is(error.message, 'Type must be a string of lowercase characters, numbers, -, or _, and must begin with a character.') | ||
}) | ||
}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add another test for when type
is not set at all
var findUserDoc = require('./utils/find-user-doc-by-username-or-id-or-token') | ||
>>>>>>> 0f0e8b3462cec11dfc4661ba1d06283f35098533 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you have to resolve the merge conflicts :) @Taekyoon
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I found it! But this is the first time that I experienced. I think it takes some time to solve it!. Just give me some time.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no rush at all :)
ran the test, and I found out some test didn't work well. The test result shows this.
|
@Taekyoon it looks like you deleted the |
Oh.. I didn't notice it because I thought I didn't deal with that code. I'll find out! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
great work 👍
@vkai also contributed this issue.
Added validating account.tokens.type in account.js that might cause invalidate form of tokens