π The open-source, offline-first Notion, Obsidian & Confluence alternative. Advanced Markdown, multi-tenant teams, OIDC/SSO, and local S3 backups. Deploy in one command.
Vue dockergolangkanbanknowledge-baseknowledge-managementmarkdownnote-takingnotesnotes-appnotionnuxtnuxtjsoffline-firstoidcpwaselfhostedssovuevuejswiki
<template>
<div class="container">
<div class="body-container">
<IconApp style="width: 120px" />
<h1>{{ t('public.login.reset.title') }}</h1>
<form class="body" @submit.prevent="reset">
<div class="form-group">
<label for="password">{{ t('public.login.form.password') }}</label>
<div class="password-input">
<input
id="password"
:key="`password-${showPassword}`"
v-model="password"
:type="showPassword ? 'text' : 'password'"
:class="{ 'is-invalid': errors.password }"
/>
<button type="button" class="password-toggle" @click="showPassword = !showPassword">
<div class="eye-icon" :class="{ show: showPassword }">
<Icon v-if="showPassword" name="eye" />
<Icon v-else name="eye_off" />
</div>
</button>
</div>
<p v-if="errors.password" class="invalid-feedback">{{ errors.password }}</p>
</div>
<div class="form-group">
<label for="confirmPassword">{{ t('public.login.form.confirmPassword') }}</label>
<div class="password-input">
<input
id="confirmPassword"
:key="`confirmPassword-${showConfirmPassword}`"
v-model="confirmPassword"
:type="showConfirmPassword ? 'text' : 'password'"
:class="{ 'is-invalid': errors.confirmPassword }"
/>
<button type="button" class="password-toggle" @click="showConfirmPassword = !showConfirmPassword">
<div class="eye-icon" :class="{ show: showConfirmPassword }">
<Icon v-if="showConfirmPassword" name="eye" />
<Icon v-else name="eye_off" />
</div>
</button>
</div>
<p v-if="errors.confirmPassword" class="invalid-feedback">{{ errors.confirmPassword }}</p>
</div>
<button type="submit" class="btn">{{ t('public.login.reset.change') }}</button>
<p v-if="errors.general" class="invalid-feedback">{{ errors.general }}</p>
<p class="sub">
<NuxtLinkLocale to="/login">{{ t('public.login.reset.done.returnToLogin') }}</NuxtLinkLocale>
</p>
</form>
</div>
</div>
</template>
<script setup lang="ts">
const userStore = useUserStore();
const { t } = useI18nT();
const password = ref('');
const confirmPassword = ref('');
const showPassword = ref(false);
const showConfirmPassword = ref(false);
const errors = ref({
password: '',
confirmPassword: '',
general: '',
});
async function reset() {
if (!password.value) errors.value.password = 'Password is required';
else if (password.value.length < 8) errors.value.password = 'Password must be at least 8 characters long';
else errors.value.password = '';
if (confirmPassword.value !== password.value) errors.value.confirmPassword = 'Passwords do not match';
else errors.value.confirmPassword = '';
if (errors.value.password || errors.value.confirmPassword) return;
userStore
.resetPassword((useRoute().query?.token as string) || '', confirmPassword.value)
.then(() => {
useRouter().push('/login');
useNotifications().add({
type: 'success',
title: 'Password changed successfully. You can now log in with your new password.',
});
})
.catch(err => (errors.value.general = err || 'An error occurred while resetting the password'));
}
</script>
<style scoped lang="scss">
.container {
display: flex;
flex-direction: column;
justify-content: space-between;
width: 95%;
height: 100%;
margin: 0 auto;
padding-top: 1.5rem;
}
.body-container {
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
width: 100%;
max-width: 600px;
margin: 0 auto 10%;
}
h1 {
font-size: 2.5em;
}
/* ===== Formulaire ===== */
form {
width: 100%;
}
.password-input {
position: relative;
}
.password-toggle {
position: absolute;
top: 50%;
right: 5px;
padding: 0.2rem;
border: none;
font-size: 0.8rem;
background-color: transparent;
outline: none;
cursor: pointer;
transform: translateY(-50%);
&:hover {
text-decoration: underline;
}
}
.form-group {
display: flex;
flex-direction: column;
width: 100%;
margin-bottom: 1rem;
}
.btn {
width: 100%;
border-radius: 50px;
font-size: 1.2rem;
color: white;
background-color: var(--primary);
&:hover {
background: var(--primary-dark);
transform: none;
}
}
input {
background: var(--surface-overlay);
outline: none;
}
.is-invalid {
border-color: var(--red) !important;
}
.invalid-feedback {
font-size: 0.8rem;
color: var(--red);
}
.sub {
font-size: 14px;
text-align: center;
a {
text-decoration: underline;
}
a:hover {
text-decoration: none;
}
}
</style>