Add the logout for the API.
continuous-integration/drone/push Build is passing

This commit is contained in:
2024-08-31 14:52:56 +03:00
parent 2f4fc790be
commit 780652241f
9 changed files with 95 additions and 6 deletions
@@ -23,4 +23,12 @@ defmodule LinkShortenerWeb.Api.V1.AccountsController do
|> render(:user, %{user: user, token: token})
end
end
def sign_out(conn, %{}) do
token = Guardian.Plug.current_token(conn)
Guardian.revoke(token)
conn
|> put_status(:ok)
|> render(:sign_out, %{token: token})
end
end
@@ -3,9 +3,15 @@ defmodule LinkShortenerWeb.Api.V1.AccountsJSON do
def user(%{user: user, token: token}) do
%{
id: user.id,
email: user.email,
token: token
}
end
def sign_out(%{token: token}) do
%{
message: "Successfully sign out",
token: token
}
end
end