feat: complete onboarding flow
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
<script setup lang="ts">
|
||||
import { deriveKey } from '~/utils/crypto';
|
||||
import { timeLeft } from '~/utils/time';
|
||||
|
||||
const { client: authClient, signUp, session } = useAuth();
|
||||
|
||||
@@ -12,8 +13,6 @@ if (session.value !== null) {
|
||||
await navigateTo(to ?? '/');
|
||||
}
|
||||
|
||||
const DAY_MS = 24 * 60 * 60 * 1000;
|
||||
|
||||
// who may register is an instance setting, admins change it while it runs
|
||||
const { data: instance } = await useFetch('/api/instance', { key: 'instance' });
|
||||
|
||||
@@ -43,9 +42,7 @@ const blocked = computed(() => inviteOnly.value && validInvite.value === null);
|
||||
const inviteValidFor = computed(() => {
|
||||
if (!validInvite.value) return '';
|
||||
|
||||
const days = Math.max(1, Math.ceil((new Date(validInvite.value.expiresAt).getTime() - Date.now()) / DAY_MS));
|
||||
|
||||
return `Invite valid for ${days} more ${days === 1 ? 'day' : 'days'}${validInvite.value.singleUse ? ' · single use' : ''}`;
|
||||
return `Invite valid for ${timeLeft(validInvite.value.expiresAt)} more${validInvite.value.singleUse ? ' · single use' : ''}`;
|
||||
});
|
||||
|
||||
const form = reactive({
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<script setup lang="ts">
|
||||
import { deriveKey } from '~/utils/crypto';
|
||||
|
||||
const { signIn } = useAuth();
|
||||
const { signIn, fetchSession } = useAuth();
|
||||
|
||||
definePageMeta({
|
||||
layout: 'auth',
|
||||
@@ -127,8 +127,11 @@ const submit = async () => {
|
||||
const key = await deriveKey(form.password, res.data.user.id);
|
||||
localStorage.setItem('encryptionKey', JSON.stringify(key));
|
||||
|
||||
// straight on to connecting a provider, the instance is useless without one
|
||||
return navigateTo('/welcome');
|
||||
// the next steps are for admins only, so make sure the role is loaded
|
||||
await fetchSession();
|
||||
|
||||
// on to the rest of the setup: who can register, then a first provider
|
||||
return navigateTo('/setup/instance');
|
||||
};
|
||||
</script>
|
||||
|
||||
@@ -160,6 +163,8 @@ const submit = async () => {
|
||||
</div>
|
||||
|
||||
<template v-else>
|
||||
<OnboardingSetupSteps :current="1"></OnboardingSetupSteps>
|
||||
|
||||
<p
|
||||
class="px-3 py-2.5 rounded-lg bg-[var(--bg-container)] border border-[var(--color-border)] text-sm leading-snug text-[var(--text-secondary)]">
|
||||
No accounts exist yet. The account you create here becomes the
|
||||
|
||||
Reference in New Issue
Block a user