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" id="confirm-password"
v-model="confirmPassword" v-model="confirmPassword"
autocomplete="new-password" autocomplete="new-password"
:label="$t('me.confirmPassword')" :label="$t('general.confirmPassword')"
/> />
<FormActionField <FormActionField
type="submit" type="submit"

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

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

6
src/i18n/locales/en.json

@ -14,8 +14,7 @@
"email": "E-Mail" "email": "E-Mail"
}, },
"me": { "me": {
"currentPassword": "Current Password", "currentPassword": "Current Password"
"confirmPassword": "Confirm Password"
}, },
"general": { "general": {
"name": "Name", "name": "Name",
@ -32,7 +31,8 @@
"host": "Host", "host": "Host",
"port": "Port", "port": "Port",
"yes": "Yes", "yes": "Yes",
"no": "No" "no": "No",
"confirmPassword": "Confirm Password"
}, },
"setup": { "setup": {
"welcome": "Welcome to your first setup of wg-easy !", "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, remember: remember,
}); });
export const UserSetupSchema = z.object({ export const UserSetupSchema = z
username: username, .object({
password: password, username: username,
}); password: password,
confirmPassword: password,
})
.refine((val) => val.password === val.confirmPassword, {
message: t('zod.user.passwordMatch'),
});
const name = z const name = z
.string({ message: t('zod.user.name') }) .string({ message: t('zod.user.name') })

Loading…
Cancel
Save