mirror of
https://akkoma.dev/AkkomaGang/akkoma.git
synced 2024-11-10 10:09:02 +00:00
29 lines
715 B
Elixir
29 lines
715 B
Elixir
defmodule Mix.Tasks.GeneratePasswordReset do
|
|
use Mix.Task
|
|
import Mix.Ecto
|
|
alias Pleroma.{Repo, User}
|
|
|
|
@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
|
|
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
|
|
)
|
|
}"
|
|
)
|
|
else
|
|
_ ->
|
|
IO.puts("No local user #{nickname}")
|
|
end
|
|
end
|
|
end
|