forked from shibao/cannery
add Accounts.is_admin?/1
This commit is contained in:
parent
76d594ca0f
commit
fc75948f4c
@ -296,6 +296,15 @@ defmodule Cannery.Accounts do
|
|||||||
list_users_by_role(:admin) |> Enum.empty?()
|
list_users_by_role(:admin) |> Enum.empty?()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@doc """
|
||||||
|
Checks if user is an admin
|
||||||
|
"""
|
||||||
|
@spec is_admin?(User.t()) :: boolean()
|
||||||
|
def is_admin?(%User{id: user_id}) do
|
||||||
|
Repo.one(from u in User, where: u.id == ^user_id and u.role == :admin)
|
||||||
|
|> is_nil()
|
||||||
|
end
|
||||||
|
|
||||||
## Confirmation
|
## Confirmation
|
||||||
|
|
||||||
@doc """
|
@doc """
|
||||||
|
Loading…
Reference in New Issue
Block a user