-
Notifications
You must be signed in to change notification settings - Fork 43
Correct user token endpoints #212
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
Conversation
| err.key = user + ', ' + tokenName; | ||
| throw err; | ||
| } | ||
|
|
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.
Let me add some tests for this check as well.
26b811b to
932a63e
Compare
0c2ac28 to
f9739e7
Compare
|
@shriramshankar @iamigo PR open for comments. |
api/v1/controllers/userTokens.js
Outdated
| ]; | ||
| whr[cnstnts.SEQ_OR][0]['user.name'][cnstnts.SEQ_LIKE] = user; | ||
| whr[cnstnts.SEQ_OR][1]['user.id'][cnstnts.SEQ_LIKE] = user; | ||
| if (u.looksLikeId()) { |
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.
if (u.looksLikeId(userNameOrId)) {
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.
|
@iamigo Corrected the uuid check. |
| // need to use '$table.field$' for association fields | ||
| whr.where = { '$User.id$': {} }; | ||
| whr.where['$User.id$'] = userNameOrId; | ||
| } else { |
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.
aren't the where clauses defined something like this ?
where : {
User: {
id: "id"
}
}
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 don't think this is working given User is an association of token table.
{ where: { User: { id: 'a568a893-0571-42b9-aa55-ca44e1308346' } } } gives me 'val.replace is not a function' error.
| // need to use '$table.field$' for association fields | ||
| whr.where = { '$User.id$': {} }; | ||
| whr.where['$User.id$'][cnstnts.SEQ_LIKE] = userNameOrId; | ||
| whr.where['$User.id$'] = userNameOrId; |
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.
Doing it this way instead of using $ilike means that we would no longer return a record with id 6da84a2a-f4b7-4ff1-b97b-56ce92501361 if we put 6da84a2a-F4B7-4ff1-b97b-56ce92501361 in the url because of uppercase/lowercase mismatch. I'm OK with that, and it's better for db performance, but then we should document that record ids in a url are case sensitive.
e73fc5e to
aff0b84
Compare
|
@iamigo Added documentation in swagger yaml. |

GET /v1/users/{key}/tokens now correctly returns tokens of given user, instead of all tokens
GET /v1/users/{key}/tokens/{tokenName} now correctly returns given token, instead of first token