Session-based OAuth auth fixes (token expiration check), refactoring, tweaks.
[akkoma] / lib / pleroma / web / o_auth / token.ex
index de37998f24578b60f28aee2c441d31840629273a..9170a7ec7daaf4fba673656f62d4e63d3da75a51 100644 (file)
@@ -27,6 +27,14 @@ defmodule Pleroma.Web.OAuth.Token do
     timestamps()
   end
 
+  @doc "Gets token by unique access token"
+  @spec get_by_token(String.t()) :: {:ok, t()} | {:error, :not_found}
+  def get_by_token(token) do
+    token
+    |> Query.get_by_token()
+    |> Repo.find_resource()
+  end
+
   @doc "Gets token for app by access token"
   @spec get_by_token(App.t(), String.t()) :: {:ok, t()} | {:error, :not_found}
   def get_by_token(%App{id: app_id} = _app, token) do