-
Notifications
You must be signed in to change notification settings - Fork 3
feat: add controllers to deal with client credentials flow #24
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
Conversation
defp validate_grant_flows(%{valid?: true, changes: %{grant_flows: flows}} = changeset) do | ||
if Enum.all?(flows, &(&1 in @possible_grant_flows)) do | ||
changeset | ||
else | ||
opts = [validation: :subset, enum: @possible_grant_flows] | ||
add_error(changeset, :grant_flows, "is invalid", opts) | ||
end | ||
end |
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.
this function is just to give a customized response?
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.
Yeah !
It's better to add the error as a changeset validation failure because that's the expected response.
This helps out a lot when we have a default controller fallback that know how to handle changeset errors.
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.
Smells like chocolate.
Now we also accepts client credentials flow on sign in endpoint.