Exclude reblogs from `GET /api/pleroma/admin/statuses` by default
[akkoma] / lib / pleroma / web / twitter_api / controllers / password_controller.ex
1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2019 Pleroma Authors <https://pleroma.social/>
3 # SPDX-License-Identifier: AGPL-3.0-only
4
5 defmodule Pleroma.Web.TwitterAPI.PasswordController do
6 @moduledoc """
7 The module containts functions for reset password.
8 """
9
10 use Pleroma.Web, :controller
11
12 require Logger
13
14 alias Pleroma.PasswordResetToken
15 alias Pleroma.Repo
16 alias Pleroma.User
17
18 def reset(conn, %{"token" => token}) do
19 with %{used: false} = token <- Repo.get_by(PasswordResetToken, %{token: token}),
20 %User{} = user <- User.get_cached_by_id(token.user_id) do
21 render(conn, "reset.html", %{
22 token: token,
23 user: user
24 })
25 else
26 _e -> render(conn, "invalid_token.html")
27 end
28 end
29
30 def do_reset(conn, %{"data" => data}) do
31 with {:ok, _} <- PasswordResetToken.reset_password(data["token"], data) do
32 render(conn, "reset_success.html")
33 else
34 _e -> render(conn, "reset_failed.html")
35 end
36 end
37 end