forked from shibao/cannery
add list user functions
This commit is contained in:
parent
18d69034ff
commit
2291da1c17
@ -59,6 +59,21 @@ defmodule Cannery.Accounts do
|
|||||||
"""
|
"""
|
||||||
def get_user!(id), do: Repo.get!(User, id)
|
def get_user!(id), do: Repo.get!(User, id)
|
||||||
|
|
||||||
|
@spec list_users_by_role(atom()) :: [User.t()]
|
||||||
|
def list_users_by_role(role) do
|
||||||
|
Repo.all(from u in User, where: u.role == ^role)
|
||||||
|
end
|
||||||
|
|
||||||
|
@spec list_all_users(boolean()) :: [User.t()]
|
||||||
|
def list_all_users(confirmed_users_only \\ true) do
|
||||||
|
if confirmed_users_only do
|
||||||
|
from u in User, where: u.confirmed_at
|
||||||
|
else
|
||||||
|
User
|
||||||
|
end
|
||||||
|
|> Repo.all()
|
||||||
|
end
|
||||||
|
|
||||||
## User registration
|
## User registration
|
||||||
|
|
||||||
@doc """
|
@doc """
|
||||||
|
Loading…
Reference in New Issue
Block a user