diff --git a/assets/js/pages/AuthPage.tsx b/assets/js/pages/AuthPage.tsx
index 2a9f1cd..d289ad6 100644
--- a/assets/js/pages/AuthPage.tsx
+++ b/assets/js/pages/AuthPage.tsx
@@ -75,6 +75,10 @@ const AuthPage = (props: AuthPageProps) => {
alert("Could not find intended link in URL");
return null;
}
+ if (!user) {
+ // no need to retrieve link if they weren't authenticated
+ return null;
+ }
const linkResponse = await fetch(`/links/${linkId}`);
let linkData: IntendedLink | null;
diff --git a/assets/js/pages/ForPage.tsx b/assets/js/pages/ForPage.tsx
index 9d03c6d..e4522c6 100644
--- a/assets/js/pages/ForPage.tsx
+++ b/assets/js/pages/ForPage.tsx
@@ -95,6 +95,7 @@ const ForPage = (props: ForPageProps) => {
value={serviceSelect}
>
+
diff --git a/lib/entendu/user_from_auth.ex b/lib/entendu/user_from_auth.ex
index 6831212..0008675 100644
--- a/lib/entendu/user_from_auth.ex
+++ b/lib/entendu/user_from_auth.ex
@@ -6,7 +6,6 @@ defmodule Entendu.UserFromAuth do
require Jason
alias Ueberauth.Auth
- alias Entendu.Links.Link
def find_or_create(%Auth{} = auth) do
{:ok, basic_info(auth)}
diff --git a/lib/entendu_web/controllers/auth_controller.ex b/lib/entendu_web/controllers/auth_controller.ex
index 512e4f6..5bcae3e 100644
--- a/lib/entendu_web/controllers/auth_controller.ex
+++ b/lib/entendu_web/controllers/auth_controller.ex
@@ -8,8 +8,6 @@ defmodule EntenduWeb.AuthController do
plug Ueberauth
alias Entendu.UserFromAuth
- alias EntenduWeb.LinkView
- alias Entendu.EncryptedLink
def delete(conn, _params) do
conn
@@ -27,7 +25,7 @@ defmodule EntenduWeb.AuthController do
def callback(%{assigns: %{ueberauth_auth: auth}} = conn, _params) do
link = get_session(conn, :intended_link)
- with %{id: link_id, recipient: recipient} <- link,
+ with %{id: link_id} <- link,
{:ok, user} <- UserFromAuth.find_or_create(auth) do
# TODO: send over encrypted data that the frontend can decrypt
diff --git a/lib/entendu_web/controllers/link_controller.ex b/lib/entendu_web/controllers/link_controller.ex
index f6eaf9c..73132c4 100644
--- a/lib/entendu_web/controllers/link_controller.ex
+++ b/lib/entendu_web/controllers/link_controller.ex
@@ -9,8 +9,6 @@ defmodule EntenduWeb.LinkController do
alias Entendu.Links
alias Links.Link
alias EntenduWeb.FallbackController
- alias Entendu.EncryptedLink
- alias Entendu.UserFromAuth
alias EntenduWeb.Plugs.AuthorizeLink
plug AuthorizeLink when action in [:text, :file]
@@ -18,7 +16,8 @@ defmodule EntenduWeb.LinkController do
action_fallback(FallbackController)
def just_page(conn, _params) do
- render(conn, "just.html")
+ conn
+ |> render("just.html")
end
def just(conn, params) do
@@ -46,7 +45,7 @@ defmodule EntenduWeb.LinkController do
end
def auth_page(conn, %{"id" => link_id}) do
- with %Link{id: id, service: service, recipient: recipient} = link <- Links.get_link(link_id) do
+ with %Link{id: id, service: service, recipient: recipient} <- Links.get_link(link_id) do
conn
|> put_session(:intended_link, %{id: id, service: service, recipient: recipient})
|> render("auth.html", %{intended_link: %{service: service, recipient: recipient}})
diff --git a/lib/entendu_web/controllers/page_controller.ex b/lib/entendu_web/controllers/page_controller.ex
index 44f74e8..46a820c 100644
--- a/lib/entendu_web/controllers/page_controller.ex
+++ b/lib/entendu_web/controllers/page_controller.ex
@@ -7,7 +7,6 @@ defmodule EntenduWeb.PageController do
def index(conn, _params) do
conn
- |> clear_session()
|> render("index.html")
end
diff --git a/lib/entendu_web/plugs/authorize_link.ex b/lib/entendu_web/plugs/authorize_link.ex
index a91e06b..d541ec6 100644
--- a/lib/entendu_web/plugs/authorize_link.ex
+++ b/lib/entendu_web/plugs/authorize_link.ex
@@ -2,11 +2,9 @@ defmodule EntenduWeb.Plugs.AuthorizeLink do
import Plug.Conn
use EntenduWeb, :controller
- alias Entendu.Repo
alias Entendu.UserFromAuth
alias Entendu.Links
alias Entendu.Links.Link
- alias EntenduWeb.FallbackController
alias EntenduWeb.ErrorView
def init(_params) do
@@ -23,7 +21,7 @@ defmodule EntenduWeb.Plugs.AuthorizeLink do
if !user do
conn
|> put_status(403)
- |> put_view(EntenduWeb.ErrorView)
+ |> put_view(ErrorView)
|> render("error_code.json", message: "Unauthorized", code: 403)
|> halt
else
@@ -35,21 +33,21 @@ defmodule EntenduWeb.Plugs.AuthorizeLink do
nil ->
conn
|> put_status(404)
- |> put_view(EntenduWeb.ErrorView)
+ |> put_view(ErrorView)
|> render("error_code.json", message: "Link could not be found", code: 404)
|> halt
false ->
conn
|> put_status(403)
- |> put_view(EntenduWeb.ErrorView)
+ |> put_view(ErrorView)
|> render("error_code.json", message: "Unauthorized", code: 403)
|> halt
{:error, reason} ->
conn
|> put_status(422)
- |> put_view(EntenduWeb.ErrorView)
+ |> put_view(ErrorView)
|> render("error_code.json", message: reason, code: 422)
|> halt
end
diff --git a/lib/entendu_web/uploaders/encrypted_link.ex b/lib/entendu_web/uploaders/encrypted_link.ex
index faf7a01..f8336cd 100644
--- a/lib/entendu_web/uploaders/encrypted_link.ex
+++ b/lib/entendu_web/uploaders/encrypted_link.ex
@@ -36,7 +36,7 @@ defmodule Entendu.EncryptedLink do
# end
# Override the storage directory:
- def storage_dir(version, {_file, scope}) do
+ def storage_dir(_version, {_file, scope}) do
"priv/uploads/links/#{scope.id}"
end