Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
This looks horrible (formatter)
defmodule Api.Authorize do
alias Account.Models.User
def board?(board_id, %User{} = user, available_permissions, required_permissions) do
with {:ok, board} <- Tracker.Board.find(board_id),
true <-
Tracker.OrganizationMembers.user_in_organization?(user.id, board.organization_id),
^required_permissions <-
Enum.to_list(
MapSet.intersection(
MapSet.new(required_permissions),
MapSet.new(available_permissions)
)
) do
true
else
_ -> false
end
end
end
@jeremytregunna

This comment has been minimized.

Copy link
Owner Author

commented Apr 29, 2018

As Jose Valim pointed out, usually a sign of needed refactoring...I did that, and this is what I ended up with: https://gist.github.com/jeremytregunna/95830562d9b3a70e0c898d9694445eb5

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.