Merge branch 'fix/no-email-no-fail' into 'develop'

Do not fail when user has no email

See merge request pleroma/pleroma!2249
This commit is contained in:
lain 2020-03-04 12:43:06 +00:00
commit 6f7a8c43a2
8 changed files with 75 additions and 3 deletions

View file

@ -99,7 +99,8 @@ defmodule Pleroma.Web.TwitterAPI.TwitterAPI do
def password_reset(nickname_or_email) do
with true <- is_binary(nickname_or_email),
%User{local: true} = user <- User.get_by_nickname_or_email(nickname_or_email),
%User{local: true, email: email} = user when not is_nil(email) <-
User.get_by_nickname_or_email(nickname_or_email),
{:ok, token_record} <- Pleroma.PasswordResetToken.create_token(user) do
user
|> UserEmail.password_reset_email(token_record.token)
@ -110,6 +111,9 @@ defmodule Pleroma.Web.TwitterAPI.TwitterAPI do
false ->
{:error, "bad user identifier"}
%User{local: true, email: nil} ->
{:ok, :noop}
%User{local: false} ->
{:error, "remote user"}