diff --git a/src/app/pages/me.vue b/src/app/pages/me.vue index 333422c3..a197f665 100644 --- a/src/app/pages/me.vue +++ b/src/app/pages/me.vue @@ -40,7 +40,7 @@ id="confirm-password" v-model="confirmPassword" autocomplete="new-password" - :label="$t('me.confirmPassword')" + :label="$t('general.confirmPassword')" /> +
+ +
{{ $t('setup.createAccount') }}
@@ -37,6 +45,7 @@ setupStore.setStep(2); const username = ref(null); const password = ref(''); +const confirmPassword = ref(''); const _submit = useSubmit( '/api/setup/2', @@ -54,6 +63,10 @@ const _submit = useSubmit( ); function submit() { - return _submit({ username: username.value, password: password.value }); + return _submit({ + username: username.value, + password: password.value, + confirmPassword: confirmPassword.value, + }); } diff --git a/src/i18n/locales/en.json b/src/i18n/locales/en.json index e78e6d99..52bcc586 100644 --- a/src/i18n/locales/en.json +++ b/src/i18n/locales/en.json @@ -14,8 +14,7 @@ "email": "E-Mail" }, "me": { - "currentPassword": "Current Password", - "confirmPassword": "Confirm Password" + "currentPassword": "Current Password" }, "general": { "name": "Name", @@ -32,7 +31,8 @@ "host": "Host", "port": "Port", "yes": "Yes", - "no": "No" + "no": "No", + "confirmPassword": "Confirm Password" }, "setup": { "welcome": "Welcome to your first setup of wg-easy !", diff --git a/src/server/database/repositories/user/types.ts b/src/server/database/repositories/user/types.ts index 276a7844..33828435 100644 --- a/src/server/database/repositories/user/types.ts +++ b/src/server/database/repositories/user/types.ts @@ -26,10 +26,15 @@ export const UserLoginSchema = z.object({ remember: remember, }); -export const UserSetupSchema = z.object({ - username: username, - password: password, -}); +export const UserSetupSchema = z + .object({ + username: username, + password: password, + confirmPassword: password, + }) + .refine((val) => val.password === val.confirmPassword, { + message: t('zod.user.passwordMatch'), + }); const name = z .string({ message: t('zod.user.name') })