Skip to content

Commit b77660b

Browse files
committed
feat: add create user & invitation endpoints
1 parent d5a1419 commit b77660b

File tree

1 file changed

+128
-1
lines changed

1 file changed

+128
-1
lines changed

src/app/web/users/page.mdx

Lines changed: 128 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -496,4 +496,131 @@ Simple authentication is the default and fallback in Drop. It relies on a simple
496496
```
497497

498498
</Col>
499-
</Row>
499+
</Row>
500+
501+
---
502+
503+
## Fetch an invitation {{ tag: 'GET', label: '/api/v1/auth/signup/simple' }}
504+
505+
<Row>
506+
<Col>
507+
508+
This endpoint is used by un-authenticated clients to fetch details about an invitation. The invitation ID acts as a secret to access invitations.
509+
510+
### Query parameters
511+
<Properties>
512+
<Property name="id" type="string">
513+
ID of invitation, fetched from the register URL.
514+
</Property>
515+
</Properties>
516+
517+
### Response parameters
518+
519+
The response parameters are the same as described in [Fetch invitation](#fetch-invitations).
520+
521+
</Col>
522+
<Col sticky>
523+
524+
<CodeGroup title="Request" tag="GET" label="/api/v1/auth/signup/simple">
525+
526+
```bash {{ title: 'cURL' }}
527+
curl -G http://localhost:3000/api/v1/auth/signup/simple?id={id}
528+
```
529+
530+
```js
531+
const response = await fetch("http://localhost:3000/api/v1/auth/signup/simple?id={id}", {});
532+
533+
const invitation = await response.json();
534+
535+
```
536+
537+
</CodeGroup>
538+
539+
```json {{ title: 'Response' }}
540+
[
541+
{
542+
"id": "418d2c3f-8029-409e-b47c-0c3b158be3e1",
543+
"isAdmin": true,
544+
"username": "testusername",
545+
"email": "[email protected]",
546+
"expires": "2025-09-23T06:37:19.047Z"
547+
}
548+
]
549+
```
550+
551+
</Col>
552+
</Row>
553+
554+
---
555+
556+
## Create user {{ tag: 'POST', label: '/api/v1/auth/signup/simple' }}
557+
558+
<Row>
559+
<Col>
560+
561+
This endpoint consumes an invitation to create a user with the Simple authentication mechanism.
562+
563+
### Request parameters
564+
<Properties>
565+
<Property name="invitation" type="string">
566+
ID of invitation, usually fetched from the register URL.
567+
</Property>
568+
<Property name="password" type="string">
569+
Password of the user. Must be >= 14 characters.
570+
</Property>
571+
<Property name="username" type="string">
572+
Username of the user. Must be set regardless if invitation will override it. Will be overriden if the invitation has it.
573+
</Property>
574+
<Property name="email" type="string">
575+
Email of the user, uses basic email validation (x\@y\.z). Must be set regardless if invitation will override it. Will be overriden if the invitation has it.
576+
</Property>
577+
<Property name="displayName" type="string">
578+
Optional, display name of user. No restrictions.
579+
</Property>
580+
</Properties>
581+
582+
</Col>
583+
<Col sticky>
584+
585+
<CodeGroup title="Request" tag="POST" label="/api/v1/auth/signup/simple">
586+
587+
```bash {{ title: 'cURL' }}
588+
curl -X POST http://localhost:3000/api/v1/auth/signup/simple?id={id} \
589+
-H "Authorization: Bearer {token}" \
590+
-H "Content-Type: application/json" \
591+
-d "{ ... }"
592+
```
593+
594+
```js
595+
const response = await fetch("http://localhost:3000/api/v1/auth/signup/simple", {
596+
method: "POST",
597+
body: {
598+
invitation: "...",
599+
username: "myUsername",
600+
601+
password: "passwordpassword123", // This is not recommended as a password
602+
displayName: "My Display Name"
603+
}
604+
});
605+
606+
const user = await response.json();
607+
608+
```
609+
610+
</CodeGroup>
611+
612+
```json {{ title: 'Response' }}
613+
{
614+
"id": "d2b487be-f796-4259-83d9-6ec27ad2947e",
615+
"username": "exampleusername",
616+
"email": "[email protected]",
617+
"displayName": "Example Username",
618+
"profilePictureObjectId": "1d5f7aeb-df75-439c-a2e9-b875af4724d2",
619+
"admin": true,
620+
"enabled": true
621+
}
622+
623+
```
624+
625+
</Col>
626+
</Row>

0 commit comments

Comments
 (0)