|
@ -1,77 +1,75 @@ |
|
|
<template> |
|
|
<template> |
|
|
<main class="container mx-auto px-4"> |
|
|
<main class="container mx-auto px-4"> |
|
|
<h1 |
|
|
<h1 |
|
|
class="text-4xl font-medium my-16 text-gray-700 dark:text-neutral-200 text-center" |
|
|
class="text-4xl font-medium my-16 text-center text-gray-700 dark:text-neutral-200" |
|
|
> |
|
|
> |
|
|
<img src="/logo.png" width="32" class="inline align-middle dark:bg" /> |
|
|
<img src="/logo.png" width="32" class="inline align-middle dark:bg" /> |
|
|
<span class="align-middle">WireGuard</span> |
|
|
<span class="align-middle">WireGuard</span> |
|
|
</h1> |
|
|
</h1> |
|
|
<div |
|
|
<Panel> |
|
|
class="flex flex-col items-center lg:w-[60%] mx-auto shadow rounded-md bg-white dark:bg-neutral-700 p-5 overflow-hidden mt-10 text-gray-700 dark:text-neutral-200" |
|
|
<PanelBody class="lg:w-[60%] mx-auto mt-10 p-4"> |
|
|
> |
|
|
<h2 class="mt-8 mb-16 text-3xl font-medium"> |
|
|
<h2 |
|
|
{{ $t('setup.welcome') }} |
|
|
class="mt-8 mb-16 text-3xl font-medium text-gray-700 dark:text-neutral-200" |
|
|
</h2> |
|
|
> |
|
|
<p class="text-lg p-8">{{ $t('setup.msg') }}</p> |
|
|
{{ $t('setup.welcome') }} |
|
|
<form class="mb-8" @submit.prevent="newAccount"> |
|
|
</h2> |
|
|
<div> |
|
|
<p class="text-lg p-8">{{ $t('setup.msg') }}</p> |
|
|
<label for="username" class="inline-block py-2">{{ |
|
|
<form class="mb-8" @submit.prevent="newAccount"> |
|
|
$t('username') |
|
|
<div> |
|
|
}}</label> |
|
|
<label for="username" class="inline-block py-2">{{ |
|
|
<input |
|
|
$t('username') |
|
|
id="username" |
|
|
}}</label> |
|
|
v-model="username" |
|
|
<input |
|
|
type="text" |
|
|
id="username" |
|
|
name="username" |
|
|
v-model="username" |
|
|
autocomplete="username" |
|
|
type="text" |
|
|
autofocus |
|
|
name="username" |
|
|
:placeholder="$t('setup.usernamePlaceholder')" |
|
|
autocomplete="username" |
|
|
class="px-3 py-2 text-sm dark:bg-neutral-700 text-gray-500 dark:text-gray-500 mb-5 border-2 border-gray-100 dark:border-neutral-800 rounded-lg w-full focus:border-red-800 dark:focus:border-red-800 dark:placeholder:text-neutral-400 focus:outline-0 focus:ring-0" |
|
|
:placeholder="$t('setup.usernamePlaceholder')" |
|
|
/> |
|
|
class="px-3 py-2 text-sm dark:bg-neutral-700 text-gray-500 dark:text-gray-500 mb-5 border-2 border-gray-100 dark:border-neutral-800 rounded-lg w-full focus:border-red-800 dark:focus:border-red-800 dark:placeholder:text-neutral-400 outline-none" |
|
|
</div> |
|
|
/> |
|
|
<div> |
|
|
</div> |
|
|
<Label for="password" class="inline-block py-2">{{ |
|
|
<div> |
|
|
$t('setup.newPassword') |
|
|
<Label for="password" class="inline-block py-2">{{ |
|
|
}}</Label> |
|
|
$t('setup.newPassword') |
|
|
<input |
|
|
}}</Label> |
|
|
id="password" |
|
|
<input |
|
|
v-model="password" |
|
|
id="password" |
|
|
type="password" |
|
|
v-model="password" |
|
|
name="password" |
|
|
type="password" |
|
|
autocomplete="new-password" |
|
|
name="password" |
|
|
:placeholder="$t('setup.passwordPlaceholder')" |
|
|
autocomplete="new-password" |
|
|
class="px-3 py-2 text-sm dark:bg-neutral-700 text-gray-500 dark:text-gray-500 mb-5 border-2 border-gray-100 dark:border-neutral-800 rounded-lg w-full focus:border-red-800 dark:focus:border-red-800 dark:placeholder:text-neutral-400 focus:outline-0 focus:ring-0" |
|
|
:placeholder="$t('setup.passwordPlaceholder')" |
|
|
/> |
|
|
class="px-3 py-2 text-sm dark:bg-neutral-700 text-gray-500 dark:text-gray-500 mb-5 border-2 border-gray-100 dark:border-neutral-800 rounded-lg w-full focus:border-red-800 dark:focus:border-red-800 dark:placeholder:text-neutral-400 outline-none" |
|
|
</div> |
|
|
/> |
|
|
<div> |
|
|
</div> |
|
|
<Label for="accept" class="inline-block my-4 mr-4">{{ |
|
|
<div> |
|
|
$t('setup.accept') |
|
|
<Label for="accept" class="inline-block my-4 mr-4">{{ |
|
|
}}</Label> |
|
|
$t('setup.accept') |
|
|
<input id="accept" v-model="accept" type="checkbox" name="accept" /> |
|
|
}}</Label> |
|
|
</div> |
|
|
<input id="accept" type="checkbox" name="accept" /> |
|
|
<button |
|
|
</div> |
|
|
type="submit" |
|
|
<button |
|
|
:class="[ |
|
|
type="submit" |
|
|
{ |
|
|
:class="[ |
|
|
'bg-red-800 dark:bg-red-800 hover:bg-red-700 dark:hover:bg-red-700 transition cursor-pointer': |
|
|
{ |
|
|
password && username, |
|
|
'bg-red-800 dark:bg-red-800 hover:bg-red-700 dark:hover:bg-red-700 transition cursor-pointer': |
|
|
'bg-gray-200 dark:bg-neutral-800 cursor-not-allowed': |
|
|
password && username, |
|
|
!password && !username, |
|
|
'bg-gray-200 dark:bg-neutral-800 cursor-not-allowed': |
|
|
}, |
|
|
!password && !username, |
|
|
'w-max px-4 rounded shadow py-2 text-sm text-white dark:text-white', |
|
|
}, |
|
|
]" |
|
|
'w-max px-4 rounded shadow py-2 text-sm text-white dark:text-white', |
|
|
> |
|
|
]" |
|
|
{{ $t('setup.submitBtn') }} |
|
|
> |
|
|
</button> |
|
|
{{ $t('setup.submitBtn') }} |
|
|
</form> |
|
|
</button> |
|
|
</PanelBody> |
|
|
</form> |
|
|
</Panel> |
|
|
</div> |
|
|
|
|
|
|
|
|
|
|
|
<ErrorToast |
|
|
<ErrorToast |
|
|
v-if="setupError" |
|
|
v-if="setupError" |
|
|
:title="setupError.title" |
|
|
:title="setupError.title" |
|
|
:message="setupError.message" |
|
|
:message="setupError.message" |
|
|
:duration="12000" |
|
|
|
|
|
/> |
|
|
/> |
|
|
</main> |
|
|
</main> |
|
|
</template> |
|
|
</template> |
|
@ -80,8 +78,10 @@ |
|
|
import { FetchError } from 'ofetch'; |
|
|
import { FetchError } from 'ofetch'; |
|
|
|
|
|
|
|
|
const { t } = useI18n(); |
|
|
const { t } = useI18n(); |
|
|
|
|
|
|
|
|
const username = ref<null | string>(null); |
|
|
const username = ref<null | string>(null); |
|
|
const password = ref<null | string>(null); |
|
|
const password = ref<null | string>(null); |
|
|
|
|
|
const accept = ref<boolean>(true); |
|
|
const authStore = useAuthStore(); |
|
|
const authStore = useAuthStore(); |
|
|
|
|
|
|
|
|
type SetupError = { |
|
|
type SetupError = { |
|
@ -95,7 +95,7 @@ watch(setupError, (value) => { |
|
|
if (value) { |
|
|
if (value) { |
|
|
setTimeout(() => { |
|
|
setTimeout(() => { |
|
|
setupError.value = null; |
|
|
setupError.value = null; |
|
|
}, 6000); |
|
|
}, 13000); |
|
|
} |
|
|
} |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
@ -103,7 +103,11 @@ async function newAccount() { |
|
|
if (!username.value || !password.value) return; |
|
|
if (!username.value || !password.value) return; |
|
|
|
|
|
|
|
|
try { |
|
|
try { |
|
|
const res = await authStore.signup(username.value, password.value); |
|
|
const res = await authStore.signup( |
|
|
|
|
|
username.value, |
|
|
|
|
|
password.value, |
|
|
|
|
|
accept.value |
|
|
|
|
|
); |
|
|
if (res) { |
|
|
if (res) { |
|
|
navigateTo('/login'); |
|
|
navigateTo('/login'); |
|
|
} |
|
|
} |
|
|