something awful login data
all the stuff to add 2 fields to the user object and to access the logged0in user in a liveview session
This commit is contained in:
@ -95,6 +95,16 @@ defmodule SomethingErlang.Accounts do
|
||||
|
||||
## Settings
|
||||
|
||||
def change_user_sadata(%User{} = user, attrs \\ %{}) do
|
||||
User.sadata_changeset(user, attrs)
|
||||
end
|
||||
|
||||
def update_sadata(%User{} = user, attrs \\ %{}) do
|
||||
user
|
||||
|> change_user_sadata(attrs)
|
||||
|> Repo.update()
|
||||
end
|
||||
|
||||
@doc """
|
||||
Returns an `%Ecto.Changeset{}` for changing the user email.
|
||||
|
||||
|
@ -8,9 +8,20 @@ defmodule SomethingErlang.Accounts.User do
|
||||
field :hashed_password, :string, redact: true
|
||||
field :confirmed_at, :naive_datetime
|
||||
|
||||
field :bbuserid, :string
|
||||
field :bbpassword, :string
|
||||
|
||||
timestamps()
|
||||
end
|
||||
|
||||
@doc """
|
||||
A user changeset for SA data.
|
||||
"""
|
||||
def sadata_changeset(user, attrs, _opts \\ []) do
|
||||
user
|
||||
|> cast(attrs, [:bbuserid, :bbpassword])
|
||||
end
|
||||
|
||||
@doc """
|
||||
A user changeset for registration.
|
||||
|
||||
|
@ -35,7 +35,8 @@ defmodule SomethingErlang.Forums do
|
||||
** (Ecto.NoResultsError)
|
||||
|
||||
"""
|
||||
def get_thread!(id), do: Repo.get!(Thread, id)
|
||||
def get_thread!(id),
|
||||
do: %Thread{id: id, thread_id: id, title: "foo"} #Repo.get!(Thread, id)
|
||||
|
||||
@doc """
|
||||
Creates a thread.
|
||||
|
Reference in New Issue
Block a user