First pass at uniformed types, specs and docs

- spec public functions (skipping controllers, views, live views and
components)
- use types instead of explanations in docs
- remove redundant docs
- fix typos
This commit is contained in:
Claudio Ortolina
2026-03-06 08:33:11 +00:00
parent 99e30d5fdf
commit 7cf9b4e7f8
81 changed files with 652 additions and 300 deletions
+3
View File
@@ -5,10 +5,12 @@ defmodule MusicLibraryWeb.Auth do
import Phoenix.Controller, only: [redirect: 2]
import Plug.Conn
@spec correct_login_password?(String.t()) :: boolean()
def correct_login_password?(password) do
Plug.Crypto.secure_compare(login_password(), password)
end
@spec require_api_token(Plug.Conn.t(), keyword()) :: Plug.Conn.t()
def require_api_token(conn, _opts) do
with ["Bearer " <> token] <- get_req_header(conn, "authorization"),
true <- Plug.Crypto.secure_compare(api_token(), token) do
@@ -31,6 +33,7 @@ defmodule MusicLibraryWeb.Auth do
|> Keyword.fetch!(:api_token)
end
@spec require_logged_in(Plug.Conn.t(), keyword()) :: Plug.Conn.t()
def require_logged_in(conn, _opts) do
if get_session(conn, :logged_in) do
conn