## `/api/pleroma/admin/invite_token`
-### Get a account registeration invite token
+### Get an account registration invite token
- Methods: `GET`
-- Params: none
+- Params:
+ - *optional* `invite` => [
+ - *optional* `max_use` (integer)
+ - *optional* `expire_at` (date string e.g. "2019-04-07")
+ ]
- Response: invite token (base64 string)
+## `/api/pleroma/admin/invites`
+
+### Get a list of generated invites
+
+- Methods: `GET`
+- Params: none
+- Response:
+
+```JSON
+{
+
+ "invites": [
+ {
+ "id": integer,
+ "token": string,
+ "used": boolean,
+ "expire_at": date,
+ "uses": integer,
+ "max_use": integer,
+ "invite_type": string (possible values: `one_time`, `reusable`, `date_limited`, `reusable_date_limited`)
+ },
+ ...
+ ]
+}
+```
+
+## `/api/pleroma/admin/revoke_invite`
+
+### Revoke invite by token
+
+- Methods: `POST`
+- Params:
+ - `token`
+- Response:
+
+```JSON
+{
+ "id": integer,
+ "token": string,
+ "used": boolean,
+ "expire_at": date,
+ "uses": integer,
+ "max_use": integer,
+ "invite_type": string (possible values: `one_time`, `reusable`, `date_limited`, `reusable_date_limited`)
+
+}
+```
+
+
## `/api/pleroma/admin/email_invite`
### Sends registration invite via email
- Methods: `POST`
- Params:
- `email`
- - `name`, optionnal
+ - `name`, optional
## `/api/pleroma/admin/password_reset`
alias Pleroma.Web.ActivityPub.Relay
alias Pleroma.Web.AdminAPI.AccountView
alias Pleroma.Web.AdminAPI.Search
-
alias Pleroma.UserInviteToken
import Pleroma.Web.ControllerHelper, only: [json_response: 3]
end
@doc "Get list of created invites"
- def invites_list(conn, _params) do
+ def invites(conn, _params) do
invites = UserInviteToken.list_invites()
conn
end
@doc "Revokes invite by token"
- def invite_revoke(conn, %{"token" => token}) do
+ def revoke_invite(conn, %{"token" => token}) do
invite = UserInviteToken.find_by_token!(token)
{:ok, updated_invite} = UserInviteToken.update_invite(invite, %{used: true})
delete("/relay", AdminAPIController, :relay_unfollow)
get("/invite_token", AdminAPIController, :get_invite_token)
- get("/invites_list", AdminAPIController, :invites_list)
- post("/invite_revoke", AdminAPIController, :invite_revoke)
+ get("/invites", AdminAPIController, :invites)
+ post("/revoke_invite", AdminAPIController, :revoke_invite)
post("/email_invite", AdminAPIController, :email_invite)
get("/password_reset", AdminAPIController, :get_password_reset)
end
end
- describe "GET /api/pleroma/admin/invites_list" do
+ describe "GET /api/pleroma/admin/invites" do
test "no invites" do
admin = insert(:user, info: %{is_admin: true})
conn =
build_conn()
|> assign(:user, admin)
- |> get("/api/pleroma/admin/invites_list")
+ |> get("/api/pleroma/admin/invites")
assert json_response(conn, 200) == %{"invites" => []}
end
conn =
build_conn()
|> assign(:user, admin)
- |> get("/api/pleroma/admin/invites_list")
+ |> get("/api/pleroma/admin/invites")
assert json_response(conn, 200) == %{
"invites" => [
end
end
- describe "POST /api/pleroma/admin/invite_revoke" do
+ describe "POST /api/pleroma/admin/revoke_invite" do
test "with token" do
admin = insert(:user, info: %{is_admin: true})
{:ok, invite} = UserInviteToken.create_invite()
conn =
build_conn()
|> assign(:user, admin)
- |> post("/api/pleroma/admin/invite_revoke", %{"token" => invite.token})
+ |> post("/api/pleroma/admin/revoke_invite", %{"token" => invite.token})
assert json_response(conn, 200) == %{
"expire_at" => nil,