2018-02-21 12:24:17 -05:00
|
|
|
defmodule Mix.Tasks.GeneratePasswordReset do
|
|
|
|
use Mix.Task
|
2018-05-04 17:25:31 -04:00
|
|
|
alias Pleroma.User
|
2018-02-21 12:24:17 -05:00
|
|
|
|
|
|
|
@shortdoc "Generate password reset link for user"
|
|
|
|
def run([nickname]) do
|
|
|
|
Mix.Task.run("app.start")
|
|
|
|
|
|
|
|
with %User{local: true} = user <- User.get_by_nickname(nickname),
|
|
|
|
{:ok, token} <- Pleroma.PasswordResetToken.create_token(user) do
|
2018-03-30 09:01:53 -04:00
|
|
|
IO.puts("Generated password reset token for #{user.nickname}")
|
|
|
|
|
|
|
|
IO.puts(
|
|
|
|
"Url: #{
|
|
|
|
Pleroma.Web.Router.Helpers.util_url(
|
|
|
|
Pleroma.Web.Endpoint,
|
|
|
|
:show_password_reset,
|
|
|
|
token.token
|
|
|
|
)
|
|
|
|
}"
|
|
|
|
)
|
2018-02-21 12:24:17 -05:00
|
|
|
else
|
|
|
|
_ ->
|
2018-03-30 09:01:53 -04:00
|
|
|
IO.puts("No local user #{nickname}")
|
2018-02-21 12:24:17 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|