1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2019 Pleroma Authors <https://pleroma.social/>
3 # SPDX-License-Identifier: AGPL-3.0-only
5 defmodule Pleroma.Web.TwitterAPI.PasswordController do
7 The module containts functions for reset password.
10 use Pleroma.Web, :controller
14 alias Pleroma.PasswordResetToken
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", %{
26 _e -> render(conn, "invalid_token.html")
30 def do_reset(conn, %{"data" => data}) do
31 with {:ok, _} <- PasswordResetToken.reset_password(data["token"], data) do
32 render(conn, "reset_success.html")
34 _e -> render(conn, "reset_failed.html")