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
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.