[Bugfix] Fix basic auth in deployed apps (#52)

* Renamed auth env vars and updated them to work in prod env

* Updated basic auth parsing to ignore empty strings
This commit is contained in:
Kieran
2024-03-04 13:29:26 -08:00
committed by GitHub
parent 5c9933b684
commit 254054c0c1
5 changed files with 22 additions and 5 deletions
+5 -1
View File
@@ -54,10 +54,14 @@ defmodule PinchflatWeb.Router do
username = Application.get_env(:pinchflat, :basic_auth_username)
password = Application.get_env(:pinchflat, :basic_auth_password)
if username && password do
if credential_set?(username) && credential_set?(password) do
Plug.BasicAuth.basic_auth(conn, username: username, password: password, realm: "Pinchflat")
else
conn
end
end
defp credential_set?(credential) do
credential && credential != ""
end
end