From: Henry Jameson Date: Sun, 17 Jun 2018 11:30:07 +0000 (+0300) Subject: Token-generating task X-Git-Url: https://git.squeep.com/?a=commitdiff_plain;h=0b1ca6a584219083e2d312abe2c1bdd8fab98e38;p=akkoma Token-generating task --- diff --git a/lib/mix/tasks/generate_invite_token.ex b/lib/mix/tasks/generate_invite_token.ex new file mode 100644 index 000000000..a5f41ef0e --- /dev/null +++ b/lib/mix/tasks/generate_invite_token.ex @@ -0,0 +1,25 @@ +defmodule Mix.Tasks.GenerateInviteToken do + use Mix.Task + + @shortdoc "Generate password reset link for user" + def run([]) do + Mix.Task.run("app.start") + + with {:ok, token} <- Pleroma.UserInviteToken.create_token() do + IO.puts("Generated user invite token") + + IO.puts( + "Url: #{ + Pleroma.Web.Router.Helpers.redirect_url( + Pleroma.Web.Endpoint, + :registration_page, + token.token + ) + }" + ) + else + _ -> + IO.puts("Error creating token") + end + end +end diff --git a/lib/pleroma/UserInviteToken.ex b/lib/pleroma/user_invite_token.ex similarity index 100% rename from lib/pleroma/UserInviteToken.ex rename to lib/pleroma/user_invite_token.ex diff --git a/lib/pleroma/web/router.ex b/lib/pleroma/web/router.ex index 127bf4d9e..dcbf7f008 100644 --- a/lib/pleroma/web/router.ex +++ b/lib/pleroma/web/router.ex @@ -344,6 +344,7 @@ defmodule Pleroma.Web.Router do end scope "/", Fallback do + get("/registration/:token", RedirectController, :registration_page) get("/*path", RedirectController, :redirector) end end @@ -358,4 +359,8 @@ defmodule Fallback.RedirectController do |> send_file(200, "priv/static/index.html") end end + + def registration_page(conn, params) do + redirector(conn, params) + end end