Open
Conversation
Contributor
|
I think it could be good to add resolver tests for this. |
vincentvanbush
requested changes
Feb 29, 2024
| :unauthorized | ||
|
|
||
| nil -> | ||
| raise Ecto.NoResultsError |
Contributor
There was a problem hiding this comment.
Since it's a library that depends on Ecto, this is acceptable, but it's possible that it could have a different behaviour since we're not actually firing any query explicitly here. (Related to #1)
| authorization_module, | ||
| resource_module, | ||
| action, | ||
| %{use_loader?: true} = meta, |
Contributor
There was a problem hiding this comment.
It could be possible to not have to use an additional use_loader? option if permit_phoenix/controller.ex allows differentiating between nil and a function at plug level. (line 365)
|
|
||
| with {_, true} <- | ||
| {:pre_auth, authorized?(subject, authorization_module, resource_module, action)}, | ||
| resource <- meta[:loader].(params_for_loader), |
Contributor
There was a problem hiding this comment.
If in permit_phoenix the loader/1 function is defined as such:
def loader(resolution_context) do
case unquote(opts)[:loader] do
nil -> nil
loader -> {:loader, unquote(__MODULE__).loader(resolution_context, unquote(opts))}
end
endyou could check here whether loader was not given at all, or it returned nil
d4876a4 to
0181070
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.