chore: import upstream snapshot with attribution
This commit is contained in:
Vendored
+29
@@ -0,0 +1,29 @@
|
||||
defmodule MyApp.Accounts.User do
|
||||
@moduledoc """
|
||||
Handles user accounts and authentication.
|
||||
"""
|
||||
|
||||
alias MyApp.Repo
|
||||
alias MyApp.Schemas.{Account, Token}
|
||||
import Ecto.Query
|
||||
|
||||
defstruct [:id, :name, :email]
|
||||
|
||||
def create(attrs) do
|
||||
%__MODULE__{}
|
||||
|> validate(attrs)
|
||||
|> Repo.insert()
|
||||
end
|
||||
|
||||
def find(id) do
|
||||
Repo.get(__MODULE__, id)
|
||||
end
|
||||
|
||||
defp validate(user, attrs) do
|
||||
if Map.has_key?(attrs, :email) do
|
||||
user
|
||||
else
|
||||
{:error, :missing_email}
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user