-
Notifications
You must be signed in to change notification settings - Fork 49
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
feat: access tokens management api #1880
Conversation
98571bc
to
b4d9d88
Compare
with {:scopes, true} <- {:scopes, "partner" not in String.split(scopes_input)}, | ||
{:ok, access_token} <- Auth.create_access_token(user, params) do | ||
conn | ||
|> put_status(201) | ||
|> json(access_token) | ||
else | ||
{:scopes, false} -> {:error, :unauthorized} | ||
{:error, _} = err -> err | ||
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.
I think that this particular code exactly matches "complex else
" anti-pattern".
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.
don't really agree that it applies in this case. The "anti-pattern" is around handling ambiguous returns from multiple different functions, where there is possible overlap of error tuples when calling different functions.
In our case, the returns are known and clearly defined given the slimness of the function, and the possible error tuples are also known and handled by the fallback controller.
Also, if we were to follow the recommendation, it would add 2 lines to the stacktrace due to the additional wrapper functions, and make the whole action function more verbose than it needs to be.
I have added more explicit tuple matching to make the error boundaries clearer. We can relook at this again in the future, but i think further refactoring has no meaningful difference.
merging in first. |
Adds in management api routes for access token management, needed for platform integration.