From 0f099dac673e707726b8498d6b56fa6f509e9467 Mon Sep 17 00:00:00 2001 From: Roger Braun Date: Sun, 19 Nov 2017 13:23:16 +0100 Subject: [PATCH] MastodonAPI: Add sign out. Close #79 --- lib/pleroma/web/mastodon_api/mastodon_api_controller.ex | 6 ++++++ lib/pleroma/web/router.ex | 9 +++++---- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/lib/pleroma/web/mastodon_api/mastodon_api_controller.ex b/lib/pleroma/web/mastodon_api/mastodon_api_controller.ex index ca1e4c8d5..9c50e850b 100644 --- a/lib/pleroma/web/mastodon_api/mastodon_api_controller.ex +++ b/lib/pleroma/web/mastodon_api/mastodon_api_controller.ex @@ -583,6 +583,12 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIController do end end + def logout(conn, _) do + conn + |> clear_session + |> redirect(to: "/") + end + def relationship_noop(%{assigns: %{user: user}} = conn, %{"id" => id}) do Logger.debug("Unimplemented, returning unmodified relationship") with %User{} = target <- Repo.get(User, id) do diff --git a/lib/pleroma/web/router.ex b/lib/pleroma/web/router.ex index beca1581e..f3c476fdc 100644 --- a/lib/pleroma/web/router.ex +++ b/lib/pleroma/web/router.ex @@ -223,12 +223,13 @@ defmodule Pleroma.Web.Router do get "/webfinger", WebFinger.WebFingerController, :webfinger end - scope "/web", Pleroma.Web.MastodonAPI do + scope "/", Pleroma.Web.MastodonAPI do pipe_through :mastodon_html - get "/login", MastodonAPIController, :login - post "/login", MastodonAPIController, :login_post - get "/*path", MastodonAPIController, :index + get "/web/login", MastodonAPIController, :login + post "/web/login", MastodonAPIController, :login_post + get "/web/*path", MastodonAPIController, :index + delete "/auth/sign_out", MastodonAPIController, :logout end scope "/", Fallback do -- 2.45.2