Giter Club home page Giter Club logo

Comments (4)

lgebhardt avatar lgebhardt commented on July 29, 2024

@barelyknown would it be possible for you to use the records method on the resource to apply the permission check? That's how I'm doing things in my code and it seems to work well. We're taking the approach that if a user doesn't have permission to see a record then they get a 404, even if the record exists. That may not work for you of course. But it does keep the logic more tightly confined to the resource.

If that doesn't work for you I'm not at all opposed to splitting up the controller methods as you proposed. It could DRY it up a bit either way.

from jsonapi-resources.

barelyknown avatar barelyknown commented on July 29, 2024

I'm using the same approach, but that doesn't work for the get_related_resource action because the records method loads the source resource, not the related resource(s).

from jsonapi-resources.

lgebhardt avatar lgebhardt commented on July 29, 2024

Good catch! In Resource._associate we could add a method similar to records for each association. Then the same approach could be used. I think that could work, but my mind's a bit tired now, so no promises.

from jsonapi-resources.

barelyknown avatar barelyknown commented on July 29, 2024

I was tired last night too!, but I thought about it more this morning and liked your suggestion. The PR implements that approach.

from jsonapi-resources.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.