@ -1,5 +1,5 @@
< template >
< template >
< main >
< 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-gray-700 dark:text-neutral-200 text-center"
>
>
@ -7,40 +7,59 @@
< span class = "align-middle" > WireGuard < / span >
< span class = "align-middle" > WireGuard < / span >
< / h1 >
< / h1 >
< div
< div
class = "shadow rounded-md bg-white dark:bg-neutral-700 mx-auto w-96 p-5 overflow-hidden mt-10 text-gray-700 dark:text-neutral-200"
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"
>
>
< h2 > Welcome to your first setup of wg - easy ! < / h2 >
< h2
< p > Please first enter an admin username and a strong password . < / p >
class = "mt-8 mb-16 text-3xl font-medium text-gray-700 dark:text-neutral-200"
< form @submit ="newAccount" >
>
{ { $t ( 'setup.welcome' ) } }
< / h2 >
< p class = "text-lg p-8" > { { $t ( 'setup.msg' ) } } < / p >
< form class = "mb-8" @submit ="newAccount" >
< div >
< div >
< label for = "username" > Username < / label >
< label for = "username" class = "inline-block py-2" > { {
$t ( 'username' )
} } < / label >
< input
< input
id = "username"
id = "username"
v - model = "username"
v - model = "username"
type = "text"
type = "text"
name = "username"
name = "username"
autocomplete = "username"
autocomplete = "username"
: 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"
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"
required = "true"
/ >
/ >
< small v-if ="errorCU" class="text-danger" > {{
$t ( 'setup.usernameCondition' )
} } < / small >
< / div >
< / div >
< div >
< div >
< label for = "password" > New Password < / label >
< label for = "password" class = "inline-block py-2" > { {
$t ( 'setup.newPassword' )
} } < / label >
< input
< input
id = "password"
id = "password"
v - model = "password"
v - model = "password"
type = "password"
type = "password"
name = "password"
name = "password"
autocomplete = "new-password"
autocomplete = "new-password"
: 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"
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"
required = "true"
/ >
/ >
< small v-if ="errorPWD" class="text-danger" > {{
$t ( 'setup.passwordCondition' )
} } < / small >
< / div >
< / div >
< div >
< div >
< label for = "accept" > I accept the condition < / label >
< label for = "accept" class = "inline-block my-4 mr-4" > { {
< input id = "accept" type = "checkbox" name = "accept" / >
$t ( 'setup.accept' )
} } < / label >
< input id = "accept" type = "checkbox" name = "accept" required = "true" / >
< / div >
< / div >
< input
< button
type = "submit"
type = "submit"
value = "Save"
: class = " [
: class = " [
{
{
'bg-red-800 dark:bg-red-800 hover:bg-red-700 dark:hover:bg-red-700 transition cursor-pointer' :
'bg-red-800 dark:bg-red-800 hover:bg-red-700 dark:hover:bg-red-700 transition cursor-pointer' :
@ -48,9 +67,11 @@
'bg-gray-200 dark:bg-neutral-800 cursor-not-allowed' :
'bg-gray-200 dark:bg-neutral-800 cursor-not-allowed' :
! password && ! username ,
! password && ! username ,
} ,
} ,
'w-full 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 >
< / form >
< / form >
< / div >
< / div >
< / main >
< / main >
@ -61,6 +82,9 @@ const username = ref<null | string>(null);
const password = ref < null | string > ( null ) ;
const password = ref < null | string > ( null ) ;
const authStore = useAuthStore ( ) ;
const authStore = useAuthStore ( ) ;
const errorCU = ref ( false ) ;
const errorPWD = ref ( false ) ;
async function newAccount ( e : Event ) {
async function newAccount ( e : Event ) {
e . preventDefault ( ) ;
e . preventDefault ( ) ;
@ -74,6 +98,7 @@ async function newAccount(e: Event) {
} catch ( error ) {
} catch ( error ) {
if ( error instanceof Error ) {
if ( error instanceof Error ) {
/ / T O D O : r e p l a c e a l e r t w i t h a c t u a l u i e r r o r m e s s a g e
/ / T O D O : r e p l a c e a l e r t w i t h a c t u a l u i e r r o r m e s s a g e
/ / T O D O : a l s o u s e e r r o r C U & e r r o r P W D t o s h o w p r o m p t e r r o r
alert ( error . message || error . toString ( ) ) ;
alert ( error . message || error . toString ( ) ) ;
}
}
}
}