[#114] Initial implementation of user password reset emails (user-initiated).
This commit is contained in:
parent
12905ce1ad
commit
f5afb11032
3 changed files with 57 additions and 1 deletions
|
|
@ -1,5 +1,9 @@
|
|||
defmodule Pleroma.Web.TwitterAPI.Controller do
|
||||
use Pleroma.Web, :controller
|
||||
|
||||
import Pleroma.Web.ControllerHelper, only: [json_response: 3]
|
||||
|
||||
alias Pleroma.Formatter
|
||||
alias Pleroma.Web.TwitterAPI.{TwitterAPI, UserView, ActivityView, NotificationView}
|
||||
alias Pleroma.Web.CommonAPI
|
||||
alias Pleroma.{Repo, Activity, Object, User, Notification}
|
||||
|
|
@ -322,6 +326,21 @@ defmodule Pleroma.Web.TwitterAPI.Controller do
|
|||
end
|
||||
end
|
||||
|
||||
def password_reset(conn, params) do
|
||||
nickname_or_email = params["email"] || params["nickname"]
|
||||
|
||||
with is_binary(nickname_or_email),
|
||||
%User{local: true} = user <- User.get_by_nickname_or_email(nickname_or_email) do
|
||||
{:ok, token_record} = Pleroma.PasswordResetToken.create_token(user)
|
||||
|
||||
user
|
||||
|> Pleroma.UserEmail.password_reset_email(token_record.token)
|
||||
|> Pleroma.Mailer.deliver()
|
||||
|
||||
json_response(conn, :no_content, "")
|
||||
end
|
||||
end
|
||||
|
||||
def update_avatar(%{assigns: %{user: user}} = conn, params) do
|
||||
{:ok, object} = ActivityPub.upload(params, type: :avatar)
|
||||
change = Changeset.change(user, %{avatar: object.data})
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue