inicontent 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/pull_request.yml +18 -0
- package/CONTRIBUTING.md +67 -0
- package/LICENSE +21 -0
- package/README.md +142 -0
- package/app/app.vue +106 -0
- package/app/assets/main.css +974 -0
- package/app/components/Api/EndpointCard.vue +169 -0
- package/app/components/Api/SchemaDocsTable.vue +208 -0
- package/app/components/Asset/Card.vue +1363 -0
- package/app/components/Asset/Grid.vue +295 -0
- package/app/components/Asset/Icon.vue +38 -0
- package/app/components/Asset/Preview.vue +486 -0
- package/app/components/Asset/Scanner.vue +700 -0
- package/app/components/Asset/Thumb.vue +708 -0
- package/app/components/Auth/Reset.vue +99 -0
- package/app/components/Auth/index.vue +346 -0
- package/app/components/ChatInterface.vue +2326 -0
- package/app/components/ChatPagePreview.vue +34 -0
- package/app/components/Column/Array.vue +29 -0
- package/app/components/Column/Asset.vue +21 -0
- package/app/components/Column/Boolean.vue +12 -0
- package/app/components/Column/Color.vue +9 -0
- package/app/components/Column/Date.vue +57 -0
- package/app/components/Column/Edit.vue +215 -0
- package/app/components/Column/Email.vue +9 -0
- package/app/components/Column/Html.vue +27 -0
- package/app/components/Column/Id.vue +20 -0
- package/app/components/Column/Locale.vue +32 -0
- package/app/components/Column/Object.vue +18 -0
- package/app/components/Column/Password.vue +7 -0
- package/app/components/Column/Role.vue +15 -0
- package/app/components/Column/S.vue +14 -0
- package/app/components/Column/Table/Single.vue +49 -0
- package/app/components/Column/Table/index.vue +42 -0
- package/app/components/Column/Tags.vue +31 -0
- package/app/components/Column/Text.vue +9 -0
- package/app/components/Column/Url.vue +9 -0
- package/app/components/Column/index.vue +41 -0
- package/app/components/Dashboard/Editor.vue +221 -0
- package/app/components/Dashboard/Grid.vue +270 -0
- package/app/components/Dashboard/View.vue +131 -0
- package/app/components/Dashboard/Widget/BarChart.vue +73 -0
- package/app/components/Dashboard/Widget/Counter.vue +51 -0
- package/app/components/Dashboard/Widget/LineChart.vue +76 -0
- package/app/components/Dashboard/Widget/PieChart.vue +75 -0
- package/app/components/Dashboard/Widget/Table.vue +94 -0
- package/app/components/Dashboard/WidgetEditor.vue +274 -0
- package/app/components/Data/Array.vue +102 -0
- package/app/components/Data/Html.vue +9 -0
- package/app/components/Data/Icon.vue +9 -0
- package/app/components/Data/Object.vue +10 -0
- package/app/components/Data/S.vue +16 -0
- package/app/components/Data/Table.vue +53 -0
- package/app/components/Data/Value.vue +34 -0
- package/app/components/Data/index.vue +14 -0
- package/app/components/Field/Array.vue +324 -0
- package/app/components/Field/Asset/Actions.vue +97 -0
- package/app/components/Field/Asset/index.vue +639 -0
- package/app/components/Field/Boolean.vue +26 -0
- package/app/components/Field/Checkbox.vue +48 -0
- package/app/components/Field/Color.vue +27 -0
- package/app/components/Field/Date.vue +30 -0
- package/app/components/Field/Email.vue +51 -0
- package/app/components/Field/EmailTemplate.vue +420 -0
- package/app/components/Field/Html/ColorPicker.vue +127 -0
- package/app/components/Field/Html/Editor.vue +544 -0
- package/app/components/Field/Html/index.vue +25 -0
- package/app/components/Field/Icon.vue +114 -0
- package/app/components/Field/JSON.vue +113 -0
- package/app/components/Field/Mention.vue +36 -0
- package/app/components/Field/Number.vue +27 -0
- package/app/components/Field/Object.vue +92 -0
- package/app/components/Field/Password.vue +55 -0
- package/app/components/Field/Radio.vue +47 -0
- package/app/components/Field/S.vue +44 -0
- package/app/components/Field/Select.vue +49 -0
- package/app/components/Field/Table.vue +348 -0
- package/app/components/Field/Tags.vue +113 -0
- package/app/components/Field/Text.vue +31 -0
- package/app/components/Field/Textarea.vue +33 -0
- package/app/components/Field/Url.vue +40 -0
- package/app/components/Field/Wrapper.vue +128 -0
- package/app/components/Field/index.vue +68 -0
- package/app/components/FloatingChatbot.vue +73 -0
- package/app/components/Form/Card.vue +151 -0
- package/app/components/Form/Drawer.vue +195 -0
- package/app/components/Form/index.vue +621 -0
- package/app/components/Header.vue +328 -0
- package/app/components/Offline/ConflictModal.vue +200 -0
- package/app/components/Offline/SyncStatus.vue +249 -0
- package/app/components/PlatformFeatureLanding.vue +65 -0
- package/app/components/Table/Backups.vue +638 -0
- package/app/components/Table/Flows.vue +814 -0
- package/app/components/Table/Grid.vue +296 -0
- package/app/components/Table/Icon.vue +36 -0
- package/app/components/Table/Logs.vue +181 -0
- package/app/components/Table/Schedules.vue +722 -0
- package/app/components/Table/Search/Button.vue +256 -0
- package/app/components/Table/Search/Items.vue +286 -0
- package/app/components/Table/Search/index.vue +87 -0
- package/app/components/Table/Settings/Schema.vue +801 -0
- package/app/components/Table/Settings/index.vue +631 -0
- package/app/components/Table/TranslateDrawer.vue +526 -0
- package/app/components/Table/Views/Kanban.vue +289 -0
- package/app/components/Table/Views/Table.vue +1273 -0
- package/app/components/Table/index.vue +890 -0
- package/app/composables/Translation/define.ts +41 -0
- package/app/composables/Translation/fetch.ts +107 -0
- package/app/composables/Translation/languages.ts +1 -0
- package/app/composables/Translation/loadCoreTranslations.ts +38 -0
- package/app/composables/Translation/translate.ts +250 -0
- package/app/composables/databaseCookies.ts +79 -0
- package/app/composables/fieldValidator.ts +72 -0
- package/app/composables/fieldsList.ts +301 -0
- package/app/composables/formatDatabase.ts +101 -0
- package/app/composables/index.ts +444 -0
- package/app/composables/openDrawer.ts +118 -0
- package/app/composables/optimizeFile.ts +287 -0
- package/app/composables/renderLabel.ts +88 -0
- package/app/composables/schemaClipboard.ts +95 -0
- package/app/composables/search.ts +353 -0
- package/app/composables/setThemeConfig.ts +48 -0
- package/app/composables/translationValue.ts +169 -0
- package/app/composables/useAssetPreview.ts +84 -0
- package/app/composables/useAssetUploader.ts +56 -0
- package/app/composables/useDashboardData.ts +310 -0
- package/app/composables/useDocumentThumbnail.ts +351 -0
- package/app/composables/useEcharts.ts +33 -0
- package/app/composables/useLocalDatabaseConfig.ts +51 -0
- package/app/composables/useOcr.ts +300 -0
- package/app/composables/useOfflineFetch.ts +194 -0
- package/app/composables/useOfflineItem.ts +107 -0
- package/app/composables/useOfflineQueue.ts +302 -0
- package/app/composables/useOfflineSync.ts +235 -0
- package/app/composables/usePasskeyAuth.ts +156 -0
- package/app/composables/usePdfCompressor.ts +180 -0
- package/app/composables/usePlatformRedirect.ts +72 -0
- package/app/composables/useRealtimeSync.ts +233 -0
- package/app/composables/useReferencedItems.ts +180 -0
- package/app/composables/useScanner.ts +664 -0
- package/app/composables/useSubscription.ts +650 -0
- package/app/composables/useThumbnailCache.ts +136 -0
- package/app/composables/useVideoCompressor.ts +194 -0
- package/app/error.vue +112 -0
- package/app/layouts/api.vue +188 -0
- package/app/layouts/dashboard.vue +91 -0
- package/app/layouts/default.vue +228 -0
- package/app/layouts/table.vue +471 -0
- package/app/locales/ar.ts +996 -0
- package/app/locales/en.ts +655 -0
- package/app/locales/es.ts +996 -0
- package/app/locales/fr.ts +997 -0
- package/app/middleware/dashboard.ts +33 -0
- package/app/middleware/database.ts +83 -0
- package/app/middleware/global.ts +1 -0
- package/app/middleware/sid-ingest.global.ts +29 -0
- package/app/middleware/table.ts +54 -0
- package/app/middleware/user.ts +26 -0
- package/app/pages/[[database]]/admin/api/auth/index.vue +306 -0
- package/app/pages/[[database]]/admin/api/index.vue +18 -0
- package/app/pages/[[database]]/admin/api/tables/[table]/index.vue +497 -0
- package/app/pages/[[database]]/admin/api/tables/index.vue +87 -0
- package/app/pages/[[database]]/admin/billing/index.vue +16 -0
- package/app/pages/[[database]]/admin/dashboards/[id]/edit.vue +66 -0
- package/app/pages/[[database]]/admin/dashboards/[id]/index.vue +117 -0
- package/app/pages/[[database]]/admin/dashboards/index.vue +20 -0
- package/app/pages/[[database]]/admin/index.vue +28 -0
- package/app/pages/[[database]]/admin/settings.vue +526 -0
- package/app/pages/[[database]]/admin/tables/[table]/[id]/edit.vue +143 -0
- package/app/pages/[[database]]/admin/tables/[table]/[id]/index.vue +146 -0
- package/app/pages/[[database]]/admin/tables/[table]/flows.vue +10 -0
- package/app/pages/[[database]]/admin/tables/[table]/index.vue +10 -0
- package/app/pages/[[database]]/admin/tables/[table]/new.vue +12 -0
- package/app/pages/[[database]]/admin/tables/[table]/schedules.vue +10 -0
- package/app/pages/[[database]]/admin/tables/[table]/settings.vue +30 -0
- package/app/pages/[[database]]/admin/tables/assets/[...path].vue +24 -0
- package/app/pages/[[database]]/admin/tables/assets/flows.vue +10 -0
- package/app/pages/[[database]]/admin/tables/backups/index.vue +10 -0
- package/app/pages/[[database]]/admin/tables/blocks/index.vue +16 -0
- package/app/pages/[[database]]/admin/tables/index.vue +20 -0
- package/app/pages/[[database]]/admin/tables/pages/index.vue +16 -0
- package/app/pages/[[database]]/admin/tables/templates/index.vue +16 -0
- package/app/pages/[[database]]/api/index.vue +120 -0
- package/app/pages/[[database]]/auth/index.vue +12 -0
- package/app/pages/[[database]]/auth/reset.vue +10 -0
- package/app/pages/[[database]]/index.vue +10 -0
- package/app/plugins/offline-warmup.client.ts +53 -0
- package/app/plugins/template-globals.ts +9 -0
- package/app/spa-loading-template.html +93 -0
- package/biome.json +53 -0
- package/index.d.ts +380 -0
- package/modules/naiveui.ts +41 -0
- package/nuxt.config.ts +269 -0
- package/package.json +56 -0
- package/pnpm-workspace.yaml +5 -0
- package/public/apple-touch-icon.png +0 -0
- package/public/favicon-16x16.png +0 -0
- package/public/favicon-32x32.png +0 -0
- package/public/favicon.ico +0 -0
- package/public/pwa-192x192.png +0 -0
- package/public/pwa-512x512.png +0 -0
- package/public/pwa-maskable-192x192.png +0 -0
- package/public/pwa-maskable-512x512.png +0 -0
- package/public/vendor/opencv.js +48 -0
- package/tsconfig.json +9 -0
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<NCard :title="t('resetPassword')" style="max-width: 300px;">
|
|
3
|
+
<NAlert v-if="!token" type="error" :title="t('invalidResetLink')" />
|
|
4
|
+
<NForm v-else ref="formRef" :model="form" @submit="submitReset">
|
|
5
|
+
<FieldS v-model="form" :schema="passwordSchema" />
|
|
6
|
+
<NButton attr-type="submit" type="primary" block secondary strong :loading="Loading.PasswordReset">
|
|
7
|
+
{{ t("resetPassword") }}
|
|
8
|
+
</NButton>
|
|
9
|
+
</NForm>
|
|
10
|
+
<template #footer>
|
|
11
|
+
<NButton text type="primary" @click="navigateTo(authPath)">
|
|
12
|
+
<template #icon><NIcon><Icon name="tabler:arrow-left" /></NIcon></template>
|
|
13
|
+
{{ t("backToSignIn") }}
|
|
14
|
+
</NButton>
|
|
15
|
+
</template>
|
|
16
|
+
</NCard>
|
|
17
|
+
</template>
|
|
18
|
+
|
|
19
|
+
<script lang="ts" setup>
|
|
20
|
+
import type { FormInst } from "naive-ui";
|
|
21
|
+
|
|
22
|
+
const config = useRuntimeConfig();
|
|
23
|
+
const route = useRoute();
|
|
24
|
+
const database = useState<Database>("database");
|
|
25
|
+
const Loading = useState<Record<string, boolean>>("Loading", () => ({}));
|
|
26
|
+
const Language = useScopedCookie<LanguagesType>("language", database.value?.slug);
|
|
27
|
+
const formRef = ref<FormInst | null>(null);
|
|
28
|
+
const form = ref({ password: "", confirmPassword: "" });
|
|
29
|
+
const token = computed(() =>
|
|
30
|
+
typeof route.query.token === "string" ? route.query.token : "",
|
|
31
|
+
);
|
|
32
|
+
const authPath = computed(() =>
|
|
33
|
+
route.params.database ? `/${database.value.slug}/auth` : "/auth",
|
|
34
|
+
);
|
|
35
|
+
const passwordSchema = computed<Schema>(() => [
|
|
36
|
+
{
|
|
37
|
+
key: "password",
|
|
38
|
+
type: "password",
|
|
39
|
+
label: t("newPassword"),
|
|
40
|
+
required: true,
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
key: "confirmPassword",
|
|
44
|
+
type: "password",
|
|
45
|
+
label: t("confirmPassword"),
|
|
46
|
+
required: true,
|
|
47
|
+
},
|
|
48
|
+
]);
|
|
49
|
+
|
|
50
|
+
async function submitReset(event: Event) {
|
|
51
|
+
event.preventDefault();
|
|
52
|
+
try {
|
|
53
|
+
await formRef.value?.validate();
|
|
54
|
+
} catch {
|
|
55
|
+
window.$message.error(t("inputsAreInvalid"));
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
if (form.value.password.length < 8) {
|
|
60
|
+
window.$message.error(t("passwordMinimumLength"));
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
if (form.value.password !== form.value.confirmPassword) {
|
|
64
|
+
window.$message.error(t("passwordsDoNotMatch"));
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
Loading.value.PasswordReset = true;
|
|
69
|
+
try {
|
|
70
|
+
const data = await $fetch<apiResponse<boolean>>(
|
|
71
|
+
`${config.public.apiBase}${database.value.slug}/auth/reset`,
|
|
72
|
+
{
|
|
73
|
+
method: "PUT",
|
|
74
|
+
body: { token: token.value, password: form.value.password },
|
|
75
|
+
credentials: "include",
|
|
76
|
+
query: { locale: Language.value },
|
|
77
|
+
},
|
|
78
|
+
);
|
|
79
|
+
if (!data.result) {
|
|
80
|
+
window.$message.error(data.message);
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
window.$message.success(data.message);
|
|
84
|
+
await navigateTo(authPath.value);
|
|
85
|
+
} catch (error: unknown) {
|
|
86
|
+
const message = (error as { data?: { message?: string } })?.data?.message;
|
|
87
|
+
window.$message.error(message ?? t("invalidResetLink"));
|
|
88
|
+
} finally {
|
|
89
|
+
Loading.value.PasswordReset = false;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
useHead(() => ({
|
|
94
|
+
title: `${t(database.value.slug)} | ${t("resetPassword")}`,
|
|
95
|
+
link: [
|
|
96
|
+
{ rel: "icon", href: database.value?.icon?.publicURL ?? "/favicon.ico" },
|
|
97
|
+
],
|
|
98
|
+
}));
|
|
99
|
+
</script>
|
|
@@ -0,0 +1,346 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<NCard hoverable style="max-width: 300px;" :style="!!props.onLoggedIn ? 'margin: auto;' : ''">
|
|
3
|
+
<NTabs ref="tabsInstRef" v-model:value="tabsValue" size="large" justify-content="center" animated>
|
|
4
|
+
<NTabPane name="signin" :tab="t('signin')">
|
|
5
|
+
<NForm ref="SigninFormRef" :model="SigninForm" @submit="SigninSubmit">
|
|
6
|
+
<FieldS v-model="SigninForm" :schema="SigninColumns" />
|
|
7
|
+
<NButtonGroup style="width: 100%;">
|
|
8
|
+
<NButton attr-type="submit" type="primary" style="flex: 1;" secondary strong :loading="Loading.Signin">
|
|
9
|
+
{{ t("signin") }}
|
|
10
|
+
</NButton>
|
|
11
|
+
<NTooltip v-if="isPasskeySupported" trigger="hover" :disabled="!passkeySigninHint">
|
|
12
|
+
<template #trigger>
|
|
13
|
+
<NButton
|
|
14
|
+
type="primary"
|
|
15
|
+
secondary
|
|
16
|
+
strong
|
|
17
|
+
:loading="Loading.PasskeySignin"
|
|
18
|
+
:disabled="!canStartPasskeySignin"
|
|
19
|
+
@click="SigninWithPasskey"
|
|
20
|
+
>
|
|
21
|
+
<template #icon>
|
|
22
|
+
<NIcon>
|
|
23
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
|
24
|
+
<circle cx="8" cy="8" r="3"/>
|
|
25
|
+
<path d="M13 8a5 5 0 0 1 5 5v1h2v2h-2v2h-2v-2h-4.17"/>
|
|
26
|
+
<line x1="8" y1="11" x2="8" y2="21"/>
|
|
27
|
+
</svg>
|
|
28
|
+
</NIcon>
|
|
29
|
+
</template>
|
|
30
|
+
</NButton>
|
|
31
|
+
</template>
|
|
32
|
+
{{ passkeySigninHint }}
|
|
33
|
+
</NTooltip>
|
|
34
|
+
</NButtonGroup>
|
|
35
|
+
<NButton text type="primary" block style="margin-top: 12px;" @click="showPasswordResetRequest = true">
|
|
36
|
+
{{ t("forgotPassword") }}
|
|
37
|
+
</NButton>
|
|
38
|
+
</NForm>
|
|
39
|
+
</NTabPane>
|
|
40
|
+
<NTabPane name="signup" :tab="t('signup')" :disabled="!table?.allowedMethods?.includes('c')">
|
|
41
|
+
<Form ref="SignupFormRef" v-model="SignupForm" table="users" @after-create="onAfterSignup" />
|
|
42
|
+
<NButton @click="SignupFormRef?.create" type="primary" block secondary strong :loading="Loading.Signup">
|
|
43
|
+
{{ t("signup") }}
|
|
44
|
+
</NButton>
|
|
45
|
+
</NTabPane>
|
|
46
|
+
</NTabs>
|
|
47
|
+
</NCard>
|
|
48
|
+
|
|
49
|
+
<NModal
|
|
50
|
+
v-model:show="showPasskeyEnrollment"
|
|
51
|
+
@esc="skipPasskeyEnrollment"
|
|
52
|
+
preset="card"
|
|
53
|
+
:title="t('passkey.enrollmentTitle')"
|
|
54
|
+
style="width: min(420px, calc(100vw - 32px));"
|
|
55
|
+
>
|
|
56
|
+
<NFlex vertical :size="16">
|
|
57
|
+
<NText>{{ t("passkey.enrollmentPrompt") }}</NText>
|
|
58
|
+
<NFlex justify="end">
|
|
59
|
+
<NButton :disabled="Loading.PasskeyRegistration" @click="skipPasskeyEnrollment">
|
|
60
|
+
{{ t("passkey.notNow") }}
|
|
61
|
+
</NButton>
|
|
62
|
+
<NButton
|
|
63
|
+
type="primary"
|
|
64
|
+
secondary
|
|
65
|
+
strong
|
|
66
|
+
:loading="Loading.PasskeyRegistration"
|
|
67
|
+
@click="registerPasskeyAfterLogin"
|
|
68
|
+
>
|
|
69
|
+
{{ t("passkey.register") }}
|
|
70
|
+
</NButton>
|
|
71
|
+
</NFlex>
|
|
72
|
+
</NFlex>
|
|
73
|
+
</NModal>
|
|
74
|
+
|
|
75
|
+
<NModal v-model:show="showPasswordResetRequest" preset="card" :title="t('forgotPassword')"
|
|
76
|
+
style="width: min(420px, calc(100vw - 32px));">
|
|
77
|
+
<NForm ref="ResetRequestFormRef" :model="ResetRequestForm" @submit="requestPasswordReset">
|
|
78
|
+
<FieldS v-model="ResetRequestForm" :schema="ResetRequestColumns" />
|
|
79
|
+
<NButton attr-type="submit" type="primary" block secondary strong :loading="Loading.PasswordResetRequest">
|
|
80
|
+
{{ t("sendResetLink") }}
|
|
81
|
+
</NButton>
|
|
82
|
+
</NForm>
|
|
83
|
+
</NModal>
|
|
84
|
+
</template>
|
|
85
|
+
|
|
86
|
+
<script lang="ts" setup>
|
|
87
|
+
import type { FormInst, TabsInst } from "naive-ui";
|
|
88
|
+
import { usePasskeyAuth } from "~/composables/usePasskeyAuth";
|
|
89
|
+
|
|
90
|
+
const props = defineProps<{onLoggedIn?: () => void}>()
|
|
91
|
+
|
|
92
|
+
const config = useRuntimeConfig();
|
|
93
|
+
const Loading = useState<Record<string, boolean>>("Loading", () => ({}));
|
|
94
|
+
const { beginPasskeySignIn, isPasskeySupported, registerCurrentUserPasskey } =
|
|
95
|
+
usePasskeyAuth();
|
|
96
|
+
|
|
97
|
+
const SigninFormRef = ref<FormInst | null>(null);
|
|
98
|
+
const ResetRequestFormRef = ref<FormInst | null>(null);
|
|
99
|
+
const route = useRoute();
|
|
100
|
+
const tabsInstRef = ref<TabsInst | null>(null);
|
|
101
|
+
const tabsValue = ref((route.query.tab as string) ?? "signin"); // Default tab
|
|
102
|
+
const database = useState<Database>("database");
|
|
103
|
+
const redirectTo = useScopedCookie<string | null>("redirectTo", database.value?.slug);
|
|
104
|
+
const table = useState<Table>("table");
|
|
105
|
+
const user = useState<User>("user");
|
|
106
|
+
const SignupForm = useState(() => ({
|
|
107
|
+
role: "b4694ff1f8c483824582c1e2dc75f0f9",
|
|
108
|
+
}));
|
|
109
|
+
const SignupFormRef = ref<FormRef>();
|
|
110
|
+
const SigninForm = ref({
|
|
111
|
+
username: "",
|
|
112
|
+
password: "",
|
|
113
|
+
});
|
|
114
|
+
const ResetRequestForm = ref({ email: "" });
|
|
115
|
+
const showPasswordResetRequest = ref(false);
|
|
116
|
+
const showPasskeyEnrollment = ref(false);
|
|
117
|
+
let resolvePasskeyEnrollment: (() => void) | undefined;
|
|
118
|
+
const canStartPasskeySignin = computed(
|
|
119
|
+
() => isPasskeySupported.value && !!SigninForm.value.username?.trim(),
|
|
120
|
+
);
|
|
121
|
+
const passkeySigninHint = computed(() => {
|
|
122
|
+
if (!SigninForm.value.username?.trim())
|
|
123
|
+
return t("passkey.signinHintUsername");
|
|
124
|
+
|
|
125
|
+
return t("passkey.signinHintDevice");
|
|
126
|
+
});
|
|
127
|
+
const SigninColumns: Schema = [
|
|
128
|
+
{
|
|
129
|
+
key: "username",
|
|
130
|
+
type: "string",
|
|
131
|
+
required: true,
|
|
132
|
+
},
|
|
133
|
+
{
|
|
134
|
+
key: "password",
|
|
135
|
+
type: "password",
|
|
136
|
+
required: true,
|
|
137
|
+
},
|
|
138
|
+
];
|
|
139
|
+
const ResetRequestColumns: Schema = [
|
|
140
|
+
{
|
|
141
|
+
key: "email",
|
|
142
|
+
type: "email",
|
|
143
|
+
required: true,
|
|
144
|
+
},
|
|
145
|
+
];
|
|
146
|
+
|
|
147
|
+
const Language = useScopedCookie<LanguagesType>("language", database.value?.slug);
|
|
148
|
+
function onAfterSignup(data?: Item) {
|
|
149
|
+
SigninForm.value.username = data?.username || "";
|
|
150
|
+
tabsValue.value = "signin";
|
|
151
|
+
tabsInstRef.value?.syncBarPosition();
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
const sessionID = useScopedCookie<string>("sid", database.value?.slug);
|
|
155
|
+
|
|
156
|
+
const isSafeRedirect = (value?: string) =>
|
|
157
|
+
!!value &&
|
|
158
|
+
value.startsWith("/") &&
|
|
159
|
+
!value.startsWith("//") &&
|
|
160
|
+
!value.endsWith("/auth") &&
|
|
161
|
+
!value.includes("/auth?");
|
|
162
|
+
|
|
163
|
+
type LoginPayload = User & { sessionID: string; hasPasskey?: boolean };
|
|
164
|
+
type LoginResponse = apiResponse<LoginPayload>;
|
|
165
|
+
|
|
166
|
+
function promptForPasskeyEnrollment() {
|
|
167
|
+
showPasskeyEnrollment.value = true;
|
|
168
|
+
return new Promise<void>((resolve) => {
|
|
169
|
+
resolvePasskeyEnrollment = resolve;
|
|
170
|
+
});
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
async function finishPasskeyEnrollment() {
|
|
174
|
+
showPasskeyEnrollment.value = false;
|
|
175
|
+
await nextTick();
|
|
176
|
+
resolvePasskeyEnrollment?.();
|
|
177
|
+
resolvePasskeyEnrollment = undefined;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
function skipPasskeyEnrollment() {
|
|
181
|
+
finishPasskeyEnrollment();
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
async function registerPasskeyAfterLogin() {
|
|
185
|
+
if (Loading.value.PasskeyRegistration === true) return;
|
|
186
|
+
|
|
187
|
+
Loading.value.PasskeyRegistration = true;
|
|
188
|
+
try {
|
|
189
|
+
const response = await registerCurrentUserPasskey();
|
|
190
|
+
window.$message.success(
|
|
191
|
+
response.message || t("passkey.registeredSuccessfully"),
|
|
192
|
+
);
|
|
193
|
+
finishPasskeyEnrollment();
|
|
194
|
+
} catch (error: unknown) {
|
|
195
|
+
window.$message.error(
|
|
196
|
+
error instanceof Error ? error.message : t("passkey.registrationFailed"),
|
|
197
|
+
);
|
|
198
|
+
} finally {
|
|
199
|
+
Loading.value.PasskeyRegistration = false;
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
async function handleSuccessfulLogin(
|
|
204
|
+
data: LoginResponse,
|
|
205
|
+
offerPasskeyEnrollment = false,
|
|
206
|
+
) {
|
|
207
|
+
sessionID.value = data.result.sessionID;
|
|
208
|
+
window.$message.success(data.message);
|
|
209
|
+
user.value = data.result;
|
|
210
|
+
database.value = (
|
|
211
|
+
await $fetch<apiResponse<Database>>(
|
|
212
|
+
`${config.public.apiBase}inicontent/databases/${database.value.slug}`,
|
|
213
|
+
{
|
|
214
|
+
credentials: "include",
|
|
215
|
+
params: {
|
|
216
|
+
[`${database.value.slug}_sid`]: sessionID.value,
|
|
217
|
+
},
|
|
218
|
+
},
|
|
219
|
+
)
|
|
220
|
+
).result;
|
|
221
|
+
|
|
222
|
+
if (!!props?.onLoggedIn) {
|
|
223
|
+
props.onLoggedIn()
|
|
224
|
+
return;
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
if (
|
|
228
|
+
offerPasskeyEnrollment &&
|
|
229
|
+
isPasskeySupported.value &&
|
|
230
|
+
!data.result.hasPasskey
|
|
231
|
+
)
|
|
232
|
+
await promptForPasskeyEnrollment();
|
|
233
|
+
|
|
234
|
+
const queryRedirectTo =
|
|
235
|
+
typeof route.query.redirectTo === "string"
|
|
236
|
+
? route.query.redirectTo
|
|
237
|
+
: undefined;
|
|
238
|
+
const target = isSafeRedirect(queryRedirectTo)
|
|
239
|
+
? queryRedirectTo
|
|
240
|
+
: isSafeRedirect(redirectTo.value ?? undefined)
|
|
241
|
+
? redirectTo.value
|
|
242
|
+
: undefined;
|
|
243
|
+
await navigateTo(
|
|
244
|
+
target
|
|
245
|
+
? target
|
|
246
|
+
: route.params.database
|
|
247
|
+
? `/${database.value.slug}/admin`
|
|
248
|
+
: "/admin",
|
|
249
|
+
);
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
async function SigninSubmit(e: Event) {
|
|
253
|
+
e.preventDefault();
|
|
254
|
+
SigninFormRef.value?.validate(async (errors) => {
|
|
255
|
+
if (!errors) {
|
|
256
|
+
const bodyContent = toRaw(SigninForm.value);
|
|
257
|
+
if (Loading.value.Signin !== true) {
|
|
258
|
+
Loading.value.Signin = true;
|
|
259
|
+
const data = await $fetch<LoginResponse>(
|
|
260
|
+
`${config.public.apiBase}${database.value.slug}/auth/signin`,
|
|
261
|
+
{
|
|
262
|
+
method: "PUT",
|
|
263
|
+
body: bodyContent,
|
|
264
|
+
params: {
|
|
265
|
+
locale: Language.value,
|
|
266
|
+
},
|
|
267
|
+
credentials: "include",
|
|
268
|
+
},
|
|
269
|
+
);
|
|
270
|
+
if (data.result?.id) {
|
|
271
|
+
await handleSuccessfulLogin(data, true);
|
|
272
|
+
} else window.$message.error(data.message);
|
|
273
|
+
Loading.value.Signin = false;
|
|
274
|
+
}
|
|
275
|
+
} else window.$message.error(t("inputsAreInvalid"));
|
|
276
|
+
});
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
async function SigninWithPasskey() {
|
|
280
|
+
if (!canStartPasskeySignin.value) {
|
|
281
|
+
window.$message.error(passkeySigninHint.value);
|
|
282
|
+
return;
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
const identifier = SigninForm.value.username.trim();
|
|
286
|
+
|
|
287
|
+
if (Loading.value.PasskeySignin === true) return;
|
|
288
|
+
|
|
289
|
+
Loading.value.PasskeySignin = true;
|
|
290
|
+
try {
|
|
291
|
+
const data = await beginPasskeySignIn(identifier);
|
|
292
|
+
if (data.result?.id) {
|
|
293
|
+
await handleSuccessfulLogin(data);
|
|
294
|
+
} else {
|
|
295
|
+
window.$message.error(data.message);
|
|
296
|
+
}
|
|
297
|
+
} catch (error: unknown) {
|
|
298
|
+
window.$message.error(
|
|
299
|
+
error instanceof Error ? error.message : t("passkey.signinFailed"),
|
|
300
|
+
);
|
|
301
|
+
} finally {
|
|
302
|
+
Loading.value.PasskeySignin = false;
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
async function requestPasswordReset(event: Event) {
|
|
307
|
+
event.preventDefault();
|
|
308
|
+
try {
|
|
309
|
+
await ResetRequestFormRef.value?.validate();
|
|
310
|
+
} catch {
|
|
311
|
+
window.$message.error(t("inputsAreInvalid"));
|
|
312
|
+
return;
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
if (Loading.value.PasswordResetRequest) return;
|
|
316
|
+
Loading.value.PasswordResetRequest = true;
|
|
317
|
+
try {
|
|
318
|
+
const data = await $fetch<apiResponse<boolean>>(
|
|
319
|
+
`${config.public.apiBase}${database.value.slug}/auth/reset`,
|
|
320
|
+
{
|
|
321
|
+
method: "POST",
|
|
322
|
+
body: toRaw(ResetRequestForm.value),
|
|
323
|
+
credentials: "include",
|
|
324
|
+
query: { locale: Language.value },
|
|
325
|
+
},
|
|
326
|
+
);
|
|
327
|
+
if (data.result) {
|
|
328
|
+
window.$message.success(data.message);
|
|
329
|
+
showPasswordResetRequest.value = false;
|
|
330
|
+
ResetRequestForm.value.email = "";
|
|
331
|
+
} else window.$message.error(data.message);
|
|
332
|
+
} catch (error: unknown) {
|
|
333
|
+
const message = (error as { data?: { message?: string } })?.data?.message;
|
|
334
|
+
window.$message.error(message ?? t("emailSendFailed"));
|
|
335
|
+
} finally {
|
|
336
|
+
Loading.value.PasswordResetRequest = false;
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
useHead(() => ({
|
|
341
|
+
title: `${t(database.value.slug)} | ${t("authentication")}`,
|
|
342
|
+
link: [
|
|
343
|
+
{ rel: "icon", href: database.value?.icon?.publicURL ?? "/favicon.ico" },
|
|
344
|
+
],
|
|
345
|
+
}));
|
|
346
|
+
</script>
|