From de255e348614767c165dfa8c8f9e9c89983d093f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Charvet=20=E9=BB=91=E7=93=9C?= Date: Thu, 27 Jun 2024 15:42:00 +0200 Subject: [PATCH] Fix dialyzer errors --- lib/teiserver/account.ex | 2 ++ lib/teiserver/account/schemas/user.ex | 3 +++ lib/teiserver/o_auth.ex | 2 +- lib/teiserver/o_auth/schemas/code.ex | 1 + lib/teiserver/o_auth/schemas/token.ex | 1 + lib/teiserver_web/controllers/o_auth/code_controller.ex | 2 +- 6 files changed, 9 insertions(+), 2 deletions(-) diff --git a/lib/teiserver/account.ex b/lib/teiserver/account.ex index 9bffb16df..6e85d5a34 100644 --- a/lib/teiserver/account.ex +++ b/lib/teiserver/account.ex @@ -9,6 +9,8 @@ defmodule Teiserver.Account do alias Teiserver.Account.UserLib + @type t :: UserLib.t() + @spec icon :: String.t() def icon, do: "fa-solid fa-user-alt" diff --git a/lib/teiserver/account/schemas/user.ex b/lib/teiserver/account/schemas/user.ex index 2792f1274..daa7ffa84 100644 --- a/lib/teiserver/account/schemas/user.ex +++ b/lib/teiserver/account/schemas/user.ex @@ -5,6 +5,9 @@ defmodule Teiserver.Account.User do alias Argon2 + # TODO: this is where a user should be defined. This is only a placeholder for now + @type t :: term() + schema "account_users" do field :name, :string field :email, :string diff --git a/lib/teiserver/o_auth.ex b/lib/teiserver/o_auth.ex index adbc38ea6..db85e9b68 100644 --- a/lib/teiserver/o_auth.ex +++ b/lib/teiserver/o_auth.ex @@ -329,7 +329,7 @@ defmodule Teiserver.OAuth do String.t(), String.t() ) :: - {:ok, Secret.t()} | {:error, term()} + {:ok, Credential.t()} | {:error, term()} def create_credentials(%Application{} = app, autohost, client_id, secret), do: create_credentials(app.id, autohost, client_id, secret) diff --git a/lib/teiserver/o_auth/schemas/code.ex b/lib/teiserver/o_auth/schemas/code.ex index 0eb5d14bb..38f37b68f 100644 --- a/lib/teiserver/o_auth/schemas/code.ex +++ b/lib/teiserver/o_auth/schemas/code.ex @@ -3,6 +3,7 @@ defmodule Teiserver.OAuth.Code do use TeiserverWeb, :schema alias Teiserver.OAuth + alias Teiserver.Account.User @type t :: %__MODULE__{ value: String.t(), diff --git a/lib/teiserver/o_auth/schemas/token.ex b/lib/teiserver/o_auth/schemas/token.ex index cf42a472b..6f1af4e06 100644 --- a/lib/teiserver/o_auth/schemas/token.ex +++ b/lib/teiserver/o_auth/schemas/token.ex @@ -3,6 +3,7 @@ defmodule Teiserver.OAuth.Token do use TeiserverWeb, :schema alias Teiserver.OAuth + alias Teiserver.Account.User @type t :: %__MODULE__{ value: String.t(), diff --git a/lib/teiserver_web/controllers/o_auth/code_controller.ex b/lib/teiserver_web/controllers/o_auth/code_controller.ex index 30dd436dc..a6728f284 100644 --- a/lib/teiserver_web/controllers/o_auth/code_controller.ex +++ b/lib/teiserver_web/controllers/o_auth/code_controller.ex @@ -3,7 +3,7 @@ defmodule TeiserverWeb.OAuth.CodeController do alias Teiserver.OAuth # https://www.rfc-editor.org/rfc/rfc6749.html#section-4.1.3 - @spec token(Conn.t(), %{}) :: Conn.t() + @spec token(Plug.Conn.t(), %{}) :: Plug.Conn.t() def token(conn, %{"grant_type" => "authorization_code"} = params) do case Enum.find(