Browse Source

Feat: Confirm setup password (#1722)

confirm setup password
pull/1725/head
Bernd Storath 4 weeks ago
committed by GitHub
parent
commit
5b68cc7311
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 2
      src/app/pages/me.vue
  2. 15
      src/app/pages/setup/2.vue
  3. 6
      src/i18n/locales/en.json
  4. 13
      src/server/database/repositories/user/types.ts

2
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')"
/>
<FormActionField
type="submit"

15
src/app/pages/setup/2.vue

@ -20,6 +20,14 @@
:label="$t('general.password')"
/>
</div>
<div class="flex flex-col">
<FormPasswordField
id="confirmPassword"
v-model="confirmPassword"
autocomplete="new-password"
:label="$t('general.confirmPassword')"
/>
</div>
<div>
<BaseButton @click="submit">{{ $t('setup.createAccount') }}</BaseButton>
</div>
@ -37,6 +45,7 @@ setupStore.setStep(2);
const username = ref<null | string>(null);
const password = ref<string>('');
const confirmPassword = ref<string>('');
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,
});
}
</script>

6
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 !",

13
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') })

Loading…
Cancel
Save