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

Solve any users can click edit or add button in experiment, score set and experiment set pages. #291

Merged
merged 8 commits into from
Oct 11, 2024

Conversation

EstelleDa
Copy link
Member

No description provided.

@EstelleDa EstelleDa requested a review from bencap October 2, 2024 07:09
Copy link
Collaborator

@bencap bencap left a comment

Choose a reason for hiding this comment

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

What if we added this as a function within the item store? Like a check permission type of deal so we only had to have it in one place? Note that I'm writing this snippet with the assumption we can pass in an action.

in src/store/modules/item.js within actions

    actionPermittedOnItem ({}, action) {
      try {
        // this response should be true to get authorization
        let response = await axios.get(`${config.apiBaseUrl}/experiment-sets/check-authorizations/${this.itemId}/action`)
        let authorized = response.data
      } catch (err) {
        console.log(`Error to get authorization:`, err)
        let authorized = False
      }
      return authorized
    }

Then we can just say this.actionPermittedOnItem("add_experiment") (or whatever action we are checking) and we can check the action is permitted on any item with the appropriately defined endpoint.

@jstone-dev might know better than me or have stronger opinions on if this is a reasonable use case of the item module. I'm a little hesitant to cache fetched permissions in the itemStore. If we are just using the permissions to decide what buttons to show to a user that seems fine, and then if permissions changed during the store lifetime they just will get an error when they try to invoke the action in question. I'm hesitant since we'd want to be careful though about doing client side filtering based on cached permission values, and I wonder if having these in the permission store makes that somewhat tempting when we shouldn't even have that possibility.

I think that if we don't want to use the itemStore for this sort of thing then your implementation looks good, we'd just need to update it for the suggested changes over in the API.

@bencap bencap added type: enhancement Enhancement to an existing feature app: frontend Task implementation touches the frontend labels Oct 2, 2024
@bencap
Copy link
Collaborator

bencap commented Oct 2, 2024

Jeremy and I talked about this and think it's probably overcomplicating it, so I think this method looks good. Once we update the backend changes we can update these and then merge them together. I think the only thing might be to rename the functions to something more descriptive about the auth, like checkUserAuthorization or something.

Copy link
Collaborator

@bencap bencap left a comment

Choose a reason for hiding this comment

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

Consider this approved, but let's wait to merge until we have the names of the routes finalized within VariantEffect/mavedb-api#325. We might need to make a couple small changes here too.

@bencap bencap merged commit 07d3d34 into release-2024.4.1 Oct 11, 2024
@bencap bencap mentioned this pull request Oct 11, 2024
@EstelleDa EstelleDa deleted the estelle/userAuthoriazationCheck branch October 14, 2024 05:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
app: frontend Task implementation touches the frontend type: enhancement Enhancement to an existing feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Login users can click 'Add an experiment' button in any experiment set.
2 participants