Skip to content
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

fixed context passing in role resolver with isOwner #3211

Closed
wants to merge 1 commit into from

Conversation

DaGaMs
Copy link
Contributor

@DaGaMs DaGaMs commented Feb 18, 2017

Description

With the move to explicit context passing of an options object, internal calls to find etc need to be updated to pass the necessary information along, too. In this case, isOwner calls findById on a Model, but does not pass an access token in options.

Related issues

Checklist

  • New tests added or existing tests modified to cover all changes
  • Code conforms with the style
    guide

@slnode
Copy link

slnode commented Feb 18, 2017

Can one of the admins verify this patch? To accept patch and trigger a build add comment ".ok\W+to\W+test."

@slnode
Copy link

slnode commented Feb 18, 2017

Can one of the admins verify this patch?

3 similar comments
@slnode
Copy link

slnode commented Feb 18, 2017

Can one of the admins verify this patch?

@slnode
Copy link

slnode commented Feb 18, 2017

Can one of the admins verify this patch?

@slnode
Copy link

slnode commented Feb 18, 2017

Can one of the admins verify this patch?

@bajtos
Copy link
Member

bajtos commented Feb 20, 2017

@slnode ok to test

Copy link
Member

@bajtos bajtos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello @DaGaMs, thank you for the pull request! Please add a test to verify this change - the test should be failing against the current master and pass with your changes in place.

@@ -218,13 +218,16 @@ module.exports = function(Role) {
* @param {Boolean} isOwner True if the user is an owner.
* @promise
*/
Role.isOwner = function isOwner(modelClass, modelId, userId, principalType, callback) {
if (!callback && typeof principalType === 'function') {
Role.isOwner = function isOwner(modelClass, modelId, userId, principalType, accessToken, callback) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should pass full options object, as it may contain additional information beyond accessToken, for example the current transaction to use when talking to an SQL datastore.

@bajtos
Copy link
Member

bajtos commented Feb 20, 2017

@DaGaMs also make sure that npm test passes on your machine.

@ebarault Since this is related to Role.isOwner method which you were changing recently, could you please take a look at the changes proposed in this pull request?

@DaGaMs
Copy link
Contributor Author

DaGaMs commented Feb 20, 2017

I had a quick look at the tests, but unfortunately it was a bit over my head to figure out how to set up a test environment with a specific set of ACL rules and an additional access hook

@ebarault
Copy link
Contributor

@bajtos: yes, i'll follow.
@DaGaMs: could you please first follow @bajtos comment in code review?

@bajtos
Copy link
Member

bajtos commented Feb 22, 2017

I had a quick look at the tests, but unfortunately it was a bit over my head to figure out how to set up a test environment with a specific set of ACL rules and an additional access hook

I'll see. I'll try to find some time this or next week to provide you with an example showing how to write such test.

@DaGaMs
Copy link
Contributor Author

DaGaMs commented Feb 22, 2017 via email

@bajtos
Copy link
Member

bajtos commented Feb 24, 2017

Hello, I have the test ready. I wanted to commit it directly into this pull request, but unfortunately committing into other people's master branch seems to not work well. @DaGaMs in the future, could you please create a feature branch for your pull requests?

I have opened a new pull request which contains the added test where I also made some small improvements in the contributed fix - see #3230.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants