Add password reset task.
This commit is contained in:
parent
eec6a87dbb
commit
765671a5b0
2 changed files with 25 additions and 0 deletions
19
lib/mix/tasks/generate_password_reset.ex
Normal file
19
lib/mix/tasks/generate_password_reset.ex
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
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
|
||||
Loading…
Add table
Add a link
Reference in a new issue