Implement access token authentication

Add whoami endpoint
This commit is contained in:
Pim Kunis 2021-06-26 00:29:33 +02:00
parent d81a42bf8a
commit dac1a429b9
8 changed files with 96 additions and 4 deletions

View file

@ -44,6 +44,15 @@ defmodule MatrixServer.Account do
|> Multi.run(:device_with_access_token, &Device.generate_access_token/2)
end
def get_by_access_token(access_token) do
from(a in Account,
join: d in assoc(a, :devices),
where: d.access_token == ^access_token,
preload: [devices: d]
)
|> Repo.one()
end
def changeset(account, params \\ %{}) do
account
|> cast(params, [:localpart, :password_hash])