add support for username authentication

This commit is contained in:
2022-02-22 00:43:16 -05:00
parent 2ac596b8c8
commit 66107c0523
5 changed files with 23 additions and 9 deletions

View File

@@ -29,7 +29,7 @@ defmodule EntenduWeb.AuthController do
with %{id: link_id, recipient: recipient} <- link,
{:ok, user} <- UserFromAuth.find_or_create(auth),
true <- UserFromAuth.can_access?(recipient, user.emails) do
true <- UserFromAuth.can_access?(recipient, user) do
# TODO: send over encrypted data that the frontend can decrypt
conn

View File

@@ -55,7 +55,7 @@ defmodule EntenduWeb.LinkController do
def text(conn, %{"id" => link_id}) do
with user = get_session(conn, :current_user),
%Link{recipient: recipient} = link <- Links.get_link(link_id),
true <- UserFromAuth.can_access?(recipient, user.emails) do
true <- UserFromAuth.can_access?(recipient, user) do
path = EncryptedLink.url({link.text_content, link})
send_file(conn, 200, path)
end
@@ -64,7 +64,7 @@ defmodule EntenduWeb.LinkController do
def file(conn, %{"id" => link_id}) do
with user = get_session(conn, :current_user),
%Link{recipient: recipient} = link <- Links.get_link(link_id),
true <- UserFromAuth.can_access?(recipient, user.emails) do
true <- UserFromAuth.can_access?(recipient, user) do
path = EncryptedLink.url({link.file_content, link})
send_file(conn, 200, path)
end