2022-10-30 16:28:14 +08:00
|
|
|
<script>
|
2024-09-30 00:23:19 +08:00
|
|
|
import CommonHelper from "@/utils/CommonHelper";
|
2025-01-02 14:37:37 +08:00
|
|
|
import CodeBlock from "@/components/base/CodeBlock.svelte";
|
|
|
|
import FieldsQueryParam from "@/components/collections/docs/FieldsQueryParam.svelte";
|
2022-10-30 16:28:14 +08:00
|
|
|
|
2023-08-15 02:20:49 +08:00
|
|
|
export let collection;
|
2022-10-30 16:28:14 +08:00
|
|
|
|
2024-09-30 00:23:19 +08:00
|
|
|
let responseTab = 200;
|
2022-10-30 16:28:14 +08:00
|
|
|
let responses = [];
|
|
|
|
|
|
|
|
$: responses = [
|
|
|
|
{
|
2024-09-30 00:23:19 +08:00
|
|
|
code: 200,
|
|
|
|
body: JSON.stringify(
|
|
|
|
{
|
|
|
|
token: "JWT_TOKEN",
|
|
|
|
record: CommonHelper.dummyCollectionRecord(collection),
|
|
|
|
},
|
|
|
|
null,
|
|
|
|
2,
|
|
|
|
),
|
2022-10-30 16:28:14 +08:00
|
|
|
},
|
|
|
|
{
|
|
|
|
code: 400,
|
|
|
|
body: `
|
|
|
|
{
|
2025-01-27 03:27:49 +08:00
|
|
|
"status": 400,
|
2022-10-30 16:28:14 +08:00
|
|
|
"message": "Failed to authenticate.",
|
|
|
|
"data": {
|
2024-09-30 00:23:19 +08:00
|
|
|
"otpId": {
|
2022-10-30 16:28:14 +08:00
|
|
|
"code": "validation_required",
|
|
|
|
"message": "Missing required value."
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
},
|
|
|
|
];
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<div class="alert alert-success">
|
|
|
|
<strong class="label label-primary">POST</strong>
|
|
|
|
<div class="content">
|
|
|
|
<p>
|
2024-09-30 00:23:19 +08:00
|
|
|
/api/collections/<strong>{collection.name}</strong>/auth-with-otp
|
2022-10-30 16:28:14 +08:00
|
|
|
</p>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="section-title">Body Parameters</div>
|
|
|
|
<table class="table-compact table-border m-b-base">
|
|
|
|
<thead>
|
|
|
|
<tr>
|
|
|
|
<th>Param</th>
|
|
|
|
<th>Type</th>
|
|
|
|
<th width="50%">Description</th>
|
|
|
|
</tr>
|
|
|
|
</thead>
|
|
|
|
<tbody>
|
|
|
|
<tr>
|
|
|
|
<td>
|
|
|
|
<div class="inline-flex">
|
|
|
|
<span class="label label-success">Required</span>
|
2024-09-30 00:23:19 +08:00
|
|
|
<span>otpId</span>
|
|
|
|
</div>
|
|
|
|
</td>
|
|
|
|
<td>
|
|
|
|
<span class="label">String</span>
|
|
|
|
</td>
|
|
|
|
<td>The id of the OTP request.</td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td>
|
|
|
|
<div class="inline-flex">
|
|
|
|
<span class="label label-success">Required</span>
|
|
|
|
<span>password</span>
|
2022-10-30 16:28:14 +08:00
|
|
|
</div>
|
|
|
|
</td>
|
|
|
|
<td>
|
|
|
|
<span class="label">String</span>
|
|
|
|
</td>
|
2024-09-30 00:23:19 +08:00
|
|
|
<td>The one-time password.</td>
|
2022-10-30 16:28:14 +08:00
|
|
|
</tr>
|
|
|
|
</tbody>
|
|
|
|
</table>
|
|
|
|
|
2025-01-02 14:37:37 +08:00
|
|
|
<div class="section-title">Query parameters</div>
|
|
|
|
<table class="table-compact table-border m-b-base">
|
|
|
|
<thead>
|
|
|
|
<tr>
|
|
|
|
<th>Param</th>
|
|
|
|
<th>Type</th>
|
|
|
|
<th width="60%">Description</th>
|
|
|
|
</tr>
|
|
|
|
</thead>
|
|
|
|
<tbody>
|
|
|
|
<tr>
|
|
|
|
<td>expand</td>
|
|
|
|
<td>
|
|
|
|
<span class="label">String</span>
|
|
|
|
</td>
|
|
|
|
<td>
|
|
|
|
Auto expand record relations. Ex.:
|
|
|
|
<CodeBlock content={`?expand=relField1,relField2.subRelField`} />
|
|
|
|
Supports up to 6-levels depth nested relations expansion. <br />
|
|
|
|
The expanded relations will be appended to the record under the
|
|
|
|
<code>expand</code> property (eg. <code>{`"expand": {"relField1": {...}, ...}`}</code>).
|
|
|
|
<br />
|
|
|
|
Only the relations to which the request user has permissions to <strong>view</strong> will be expanded.
|
|
|
|
</td>
|
|
|
|
</tr>
|
|
|
|
<FieldsQueryParam prefix="record." />
|
|
|
|
</tbody>
|
|
|
|
</table>
|
|
|
|
|
2022-10-30 16:28:14 +08:00
|
|
|
<div class="section-title">Responses</div>
|
|
|
|
<div class="tabs">
|
2023-09-01 17:44:43 +08:00
|
|
|
<div class="tabs-header compact combined left">
|
2022-10-30 16:28:14 +08:00
|
|
|
{#each responses as response (response.code)}
|
|
|
|
<button
|
|
|
|
class="tab-item"
|
|
|
|
class:active={responseTab === response.code}
|
|
|
|
on:click={() => (responseTab = response.code)}
|
|
|
|
>
|
|
|
|
{response.code}
|
|
|
|
</button>
|
|
|
|
{/each}
|
|
|
|
</div>
|
|
|
|
<div class="tabs-content">
|
|
|
|
{#each responses as response (response.code)}
|
|
|
|
<div class="tab-item" class:active={responseTab === response.code}>
|
|
|
|
<CodeBlock content={response.body} />
|
|
|
|
</div>
|
|
|
|
{/each}
|
|
|
|
</div>
|
|
|
|
</div>
|