feat: review backend and frontend
- update to the latest version of Java/SpringBoot - update to the latest version NuxtJS - add account/password update - add account creation - add account password reset - add bundle to regroup questions and add default questions on user creation - add bundle creation
This commit is contained in:
128
frontend/pages/account/create.vue
Normal file
128
frontend/pages/account/create.vue
Normal file
@@ -0,0 +1,128 @@
|
||||
<script lang="ts" setup>
|
||||
|
||||
import {useNotificationStore} from "~/store/notification";
|
||||
import {useAccountStore} from "~/store/account";
|
||||
import type {ApiError} from "~/composables/fetch-api";
|
||||
|
||||
definePageMeta({
|
||||
layout: 'main-header'
|
||||
});
|
||||
|
||||
const email = ref();
|
||||
const username = ref();
|
||||
const emailConfirmation = ref();
|
||||
const password = ref();
|
||||
const confirmationPassword = ref();
|
||||
const conditionChecked = ref(false);
|
||||
const cguModalVisible = ref(false);
|
||||
|
||||
function createAccount() {
|
||||
if (emailConfirmation.value !== email.value) {
|
||||
useNotificationStore().pushNotification("warn", {message: "Saisir le même e-mail dans les champs 'E-mail' et 'Confirmation de l'e-mail'."});
|
||||
} else if (password.value !== confirmationPassword.value) {
|
||||
useNotificationStore().pushNotification("warn", {message: "Saisir le même mot de passe dans les champs 'Mot de passe' et 'Confirmation du mot de passe'."});
|
||||
} else {
|
||||
useAccountStore().create(username.value, email.value, password.value)
|
||||
.then(() => {
|
||||
useNotificationStore().pushNotification("success", {
|
||||
message: "Votre compte a bien été créé.",
|
||||
details: "Vous allez recevoir un e-mail."
|
||||
});
|
||||
navigateTo("/login");
|
||||
})
|
||||
.catch((apiError: ApiError) => {
|
||||
let details;
|
||||
if (apiError.fieldErrors) {
|
||||
details = apiError.fieldErrors.map(error => `${error.fields!.join(", ")} ${error.detail}`);
|
||||
}
|
||||
useNotificationStore().pushNotification("warn", {message: apiError.message, details});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
</script>
|
||||
<template>
|
||||
<div>
|
||||
<section>
|
||||
<h1>Créer un compte</h1>
|
||||
<form class="form" @submit.prevent="createAccount">
|
||||
<label for="username">Nom de l'équipe *</label>
|
||||
<input id="username" v-model="username" type="text" autocomplete="username" required>
|
||||
<label for="email">E-mail *</label>
|
||||
<input id="email" v-model="email" type="email" autocomplete="email" required>
|
||||
<label for="emailConfirmation">Confirmation de l'e-mail *</label>
|
||||
<input id="emailConfirmation" v-model="emailConfirmation" type="email" required>
|
||||
<p class="form__help">Votre mot de passe doit fait au moins 8 caractères, et être composé d’au moins une
|
||||
majuscule, une minuscule,
|
||||
un chiffre de 0 à 9, et un caractère spécial parmi @?!#$&;,:</p>
|
||||
<label for="newPassword">Mot de passe *</label>
|
||||
<input id="newPassword" v-model="password" type="password" required>
|
||||
<label for="confirmationPassword">Confirmation du mot de passe *</label>
|
||||
<input id="confirmationPassword" v-model="confirmationPassword" type="password" required>
|
||||
<label>
|
||||
<input type="checkbox" v-model="conditionChecked" required />
|
||||
En continuant, j’accepte
|
||||
<button class="button-link" @click="cguModalVisible = true" type="button">les conditions d'utilisation de Boussole PLUSS et j’ai lu la politique de
|
||||
confidentialité
|
||||
</button>
|
||||
</label>
|
||||
<div class="button-container">
|
||||
<nuxt-link class="button gray button-back" to="/login" aria-label="Retour à la page précédente">❮</nuxt-link>
|
||||
<button class="button orange" type="submit" :disabled="!conditionChecked">Enregistrer</button>
|
||||
</div>
|
||||
</form>
|
||||
</section>
|
||||
</div>
|
||||
<cgu-modal :visible="cguModalVisible" @close="cguModalVisible = false; conditionChecked = false;" @validate="conditionChecked = true; cguModalVisible = false"/>
|
||||
</template>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
@import "assets/css/spacing";
|
||||
|
||||
.form {
|
||||
|
||||
//.checkbox {
|
||||
// input {
|
||||
// position: absolute;
|
||||
// opacity: 0;
|
||||
// cursor: pointer;
|
||||
// height: 0;
|
||||
// width: 0;
|
||||
// }
|
||||
// input:checked ~ &-checkmark:after {
|
||||
// display: block;
|
||||
// }
|
||||
//
|
||||
// &-checkmark {
|
||||
// position: absolute;
|
||||
// top: 0;
|
||||
// left: 0;
|
||||
// height: 25px;
|
||||
// width: 25px;
|
||||
// background-color: #eee;
|
||||
//
|
||||
// &:after {
|
||||
// left: 9px;
|
||||
// top: 5px;
|
||||
// width: 5px;
|
||||
// height: 10px;
|
||||
// border: solid white;
|
||||
// border-width: 0 3px 3px 0;
|
||||
// rotate: 45deg;
|
||||
// }
|
||||
// }
|
||||
// &-checkmark:after {
|
||||
// content: "";
|
||||
// position: absolute;
|
||||
// display: none;
|
||||
// }
|
||||
// &:hover input ~ &-checkmark {
|
||||
// background-color: #ccc;
|
||||
// }
|
||||
//}
|
||||
input[type="checkbox"] {
|
||||
grid-column: span 2 / 3;
|
||||
margin-top: $medium;
|
||||
}
|
||||
}
|
||||
</style>
|
68
frontend/pages/account/index.vue
Normal file
68
frontend/pages/account/index.vue
Normal file
@@ -0,0 +1,68 @@
|
||||
<script lang="ts" setup>
|
||||
|
||||
import {useAccountStore} from "~/store/account";
|
||||
import {useNotificationStore} from "~/store/notification";
|
||||
import {useAuthStore} from "~/store/auth";
|
||||
import type {ApiError} from "~/composables/fetch-api";
|
||||
|
||||
const email = ref(useAuthStore().user.email);
|
||||
const username = ref(useAuthStore().user.username);
|
||||
const emailConfirmation = ref();
|
||||
|
||||
function updateAccount() {
|
||||
if (emailConfirmation.value !== email.value) {
|
||||
useNotificationStore().pushNotification("warn", {message: "Saisir le même e-mail dans les champs 'E-mail' et 'Confirmation de l'e-mail'."});
|
||||
} else {
|
||||
useAccountStore().update(username.value, email.value)
|
||||
.then(async () => {
|
||||
if (useAuthStore().user.email !== email.value) {
|
||||
await useAuthStore().refreshSession();
|
||||
}
|
||||
useNotificationStore().pushNotification("success", {message: "Votre compte a bien été mis à jour."});
|
||||
useAuthStore().user.username = username.value;
|
||||
navigateTo("/bundle");
|
||||
})
|
||||
.catch((apiError: ApiError) => {
|
||||
let details;
|
||||
if (apiError.fieldErrors) {
|
||||
details = apiError.fieldErrors.map(error => `${error.fields!.join(", ")} ${error.detail}`);
|
||||
}
|
||||
useNotificationStore().pushNotification("warn", {message: apiError.message, details});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
</script>
|
||||
<template>
|
||||
<div>
|
||||
<section>
|
||||
<h1>Mon compte</h1>
|
||||
<form class="form" @submit.prevent="updateAccount">
|
||||
<label for="username">Nom de l'équipe *</label>
|
||||
<input id="username" v-model="username" type="text" autocomplete="username" required>
|
||||
<label for="email">E-mail *</label>
|
||||
<input id="email" v-model="email" type="email" autocomplete="email" required>
|
||||
<label for="emailConfirmation">Confirmation de l'e-mail *</label>
|
||||
<input id="emailConfirmation" v-model="emailConfirmation" type="email" required>
|
||||
<button class="button orange" type="submit">Enregistrer</button>
|
||||
</form>
|
||||
<div class="button-container">
|
||||
<nuxt-link to="/bundle" class="button gray button-back" aria-label="Retour à la page principale">❮
|
||||
</nuxt-link>
|
||||
<nuxt-link to="/account/password" class="button blue" type="submit">Modifier mon mot de passe</nuxt-link>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
@import "assets/css/spacing";
|
||||
|
||||
.form {
|
||||
& [type="submit"] {
|
||||
grid-column: span 2 / 3;
|
||||
margin-top: $small;
|
||||
}
|
||||
|
||||
}
|
||||
</style>
|
55
frontend/pages/account/password/confirm-reset.vue
Normal file
55
frontend/pages/account/password/confirm-reset.vue
Normal file
@@ -0,0 +1,55 @@
|
||||
<script lang="ts" setup>
|
||||
import {useAccountStore} from "~/store/account";
|
||||
import type {ApiError} from "~/composables/fetch-api";
|
||||
import {useNotificationStore} from "~/store/notification";
|
||||
|
||||
definePageMeta({
|
||||
layout: 'main-header'
|
||||
});
|
||||
|
||||
const email = ref();
|
||||
const newPassword = ref();
|
||||
const confirmationPassword = ref();
|
||||
|
||||
onMounted(() => {
|
||||
if (!useRoute().query.token) {
|
||||
navigateTo("/");
|
||||
}
|
||||
});
|
||||
|
||||
function resetPassword() {
|
||||
const token = useRoute().query.token;
|
||||
useAccountStore().resetPassword(token, email.value, newPassword.value, confirmationPassword.value)
|
||||
.then(() => {
|
||||
useNotificationStore().pushNotification("success", {message: "Votre mot de passe a bien été ré-initialisé."});
|
||||
navigateTo("/login");
|
||||
})
|
||||
.catch((apiError: ApiError) => {
|
||||
let details;
|
||||
if (apiError.fieldErrors) {
|
||||
details = apiError.fieldErrors.map(error => `${error.fields!.join(", ")} ${error.detail}`);
|
||||
}
|
||||
useNotificationStore().pushNotification("warn", {message: apiError.message, details});
|
||||
});
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<section>
|
||||
<h1>Ré-initialisé mon mot de passe</h1>
|
||||
<form class="form" @submit.prevent="resetPassword">
|
||||
<label for="email">Mon e-mail</label>
|
||||
<input id="email" v-model="email" type="email" autocomplete="username" required>
|
||||
<p class="form__help">Votre mot de passe doit fait au moins 8 caractères, et être composé d’au moins une
|
||||
majuscule, une minuscule, un chiffre de 0 à 9, et un caractère spécial parmi @?!#$&;,:</p>
|
||||
<label for="newPassword">Nouveau mot de passe</label>
|
||||
<input id="newPassword" v-model="newPassword" type="password" required>
|
||||
<label for="confirmationPassword">Confirmation du mot de passe</label>
|
||||
<input id="confirmationPassword" v-model="confirmationPassword" type="password" required>
|
||||
<div class="button-container">
|
||||
<button class="button orange" type="submit">Enregistrer</button>
|
||||
</div>
|
||||
</form>
|
||||
</section>
|
||||
</template>
|
||||
|
46
frontend/pages/account/password/index.vue
Normal file
46
frontend/pages/account/password/index.vue
Normal file
@@ -0,0 +1,46 @@
|
||||
<script lang="ts" setup>
|
||||
import {useAccountStore} from "~/store/account";
|
||||
import type {ApiError} from "~/composables/fetch-api";
|
||||
import {useNotificationStore} from "~/store/notification";
|
||||
|
||||
const currentPassword = ref();
|
||||
const newPassword = ref();
|
||||
const confirmationPassword = ref();
|
||||
|
||||
function updatePassword() {
|
||||
useAccountStore().updatePassword(currentPassword.value, newPassword.value, confirmationPassword.value)
|
||||
.then(() => {
|
||||
useNotificationStore().pushNotification("success",{message: "Votre mot de passe a bien été modifié."});
|
||||
navigateTo("/account");
|
||||
})
|
||||
.catch((apiError: ApiError) => {
|
||||
let details;
|
||||
if (apiError.fieldErrors) {
|
||||
details = apiError.fieldErrors.map(error => `${error.fields!.join(", ")} ${error.detail}`);
|
||||
}
|
||||
useNotificationStore().pushNotification("warn",{message: apiError.message, details});
|
||||
});
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<section>
|
||||
<h1>Modifier mon mot de passe</h1>
|
||||
<form class="form" @submit.prevent="updatePassword">
|
||||
<label for="currentPassword">Mot de passe actuel</label>
|
||||
<input id="currentPassword" v-model="currentPassword" type="password" autocomplete="currentPassword" required>
|
||||
<p class="form__help">Votre mot de passe doit fait au moins 8 caractères, et être composé d’au moins une
|
||||
majuscule, une minuscule,
|
||||
un chiffre de 0 à 9, et un caractère spécial parmi @?!#$&;,:</p>
|
||||
<label for="newPassword">Nouveau mot de passe</label>
|
||||
<input id="newPassword" v-model="newPassword" type="password" required>
|
||||
<label for="confirmationPassword">Confirmation du mot de passe</label>
|
||||
<input id="confirmationPassword" v-model="confirmationPassword" type="password" required>
|
||||
<div class="button-container">
|
||||
<nuxt-link class="button gray button-back" to="/account" aria-label="Retour à la page précédente">❮</nuxt-link>
|
||||
<button class="button orange" type="submit">Enregistrer</button>
|
||||
</div>
|
||||
</form>
|
||||
</section>
|
||||
</template>
|
||||
|
61
frontend/pages/account/password/reset.vue
Normal file
61
frontend/pages/account/password/reset.vue
Normal file
@@ -0,0 +1,61 @@
|
||||
<script lang="ts" setup>
|
||||
import {useAccountStore} from "~/store/account";
|
||||
import {useNotificationStore} from "~/store/notification";
|
||||
import type {ApiError} from "~/composables/fetch-api";
|
||||
|
||||
definePageMeta({
|
||||
layout: 'main-header'
|
||||
});
|
||||
|
||||
const email = ref();
|
||||
const loading = ref(false);
|
||||
|
||||
function sendEmail() {
|
||||
loading.value = true;
|
||||
useAccountStore()
|
||||
.requestPasswordReset(email.value)
|
||||
.then(() => {
|
||||
useNotificationStore().pushNotification("success", {message: "Consultez vos emails pour réinitialiser votre mot de passe."})
|
||||
navigateTo("login");
|
||||
})
|
||||
.catch((apiError: ApiError) => {
|
||||
let details;
|
||||
if (apiError.fieldErrors) {
|
||||
details = apiError.fieldErrors.map(error => `${error.fields!.join(", ")} ${error.detail}`);
|
||||
}
|
||||
useNotificationStore().pushNotification("warn", {message: apiError.message, details});
|
||||
})
|
||||
.finally(() => {
|
||||
loading.value = false;
|
||||
});
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<section>
|
||||
<h1>Mot de passe oublié</h1>
|
||||
<form class="form" @submit.prevent="sendEmail">
|
||||
<p>Entrez votre email pour recevoir un lien permettant de réinitialiser le mot de passe associé à votre
|
||||
compte.</p>
|
||||
<input v-model="email" type="email" placeholder="E-mail" required/>
|
||||
<div class="button-container">
|
||||
<nuxt-link class="button gray button-back" to="/login" aria-label="Retour à la page de login">❮</nuxt-link>
|
||||
<button class="button orange" type="submit">Envoyer l'e-mail</button>
|
||||
</div>
|
||||
<loader class="loader" v-if="loading"/>
|
||||
</form>
|
||||
</section>
|
||||
</template>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.form {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: $small;
|
||||
}
|
||||
|
||||
.loader {
|
||||
align-self: center;
|
||||
}
|
||||
</style>
|
Reference in New Issue
Block a user