-
Notifications
You must be signed in to change notification settings - Fork 86
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
Remove JaResource for StripeConnectSubscriptions #1041
Remove JaResource for StripeConnectSubscriptions #1041
Conversation
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.
Couple of things to fix, but otherwise, good work 👍
def create?(user, subscription), do: user |> owns?(subscription) | ||
|
||
@spec show?(User.t, map) :: boolean |
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.
These specs should be the other way around
@spec create?(User.t, map) :: boolean
def create?(user, params), do: user |> owns?(subscription)
@spec show?(User.t, StripeConnectSubscription.t) :: boolean
def show?(user, subscription), do: user |> owns?(subscription)
def model, do: CodeCorps.StripeConnectSubscription | ||
@spec show(Conn.t, map) :: Conn.t | ||
def show(%Conn{} = conn, %{"id" => id}) do | ||
with %StripeConnectSubscription{} = subscription <- StripeConnectSubscription |> Repo.get(id) do |
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're missing an authorization step here.
with %StripeConnectSubscription{} = subscription <- StripeConnectSubscription |> Repo.get(id),
{:ok, :authorized} <- current_user |> Policy.authorize(:create, subscription, params) do # params are optional
conn |> render("show.json-api", data: subscription)
end
c916319
to
953fb26
Compare
@begedin Thanks for the feedback! Can you take another look to make sure the implementation is correct? I went back to |
@landongrindheim Good job noticing that. Feel free to create an issue in cases such as that one. My approach to it is, always better to close an issue when one was made by mistake, than to forget to open it in the first place. |
Excellent work as always @landongrindheim |
Remove JaResource/Canary for StripeConnectSubscriptionController
References
Closes #907
Progress on: #864