Token-generating task
authorHenry Jameson <me@hjkos.com>
Sun, 17 Jun 2018 11:30:07 +0000 (14:30 +0300)
committerHenry Jameson <me@hjkos.com>
Sun, 17 Jun 2018 11:30:07 +0000 (14:30 +0300)
lib/mix/tasks/generate_invite_token.ex [new file with mode: 0644]
lib/pleroma/user_invite_token.ex [moved from lib/pleroma/UserInviteToken.ex with 100% similarity]
lib/pleroma/web/router.ex

diff --git a/lib/mix/tasks/generate_invite_token.ex b/lib/mix/tasks/generate_invite_token.ex
new file mode 100644 (file)
index 0000000..a5f41ef
--- /dev/null
@@ -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
index 127bf4d9eed371e30d2920f6ee1a7541546d98da..dcbf7f0082e300cdf7c85dfbf371c83b6753cfd8 100644 (file)
@@ -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