[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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user