Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ module.exports = async function register(req, res, next) {
const checkUser = await User.read({ mail: email });
if (checkUser && checkUser.length !== 0) {
log.w("Utilisateur déjà existant");

try {
await Send(
MailUtils.usagers.authentication.sendAccountAlreadyExist({
Expand All @@ -51,7 +52,13 @@ module.exports = async function register(req, res, next) {
}),
);
}
return res.status(200).json({ code: "CreationCompte" });

return next(
new AppError("Un compte avec cet email existe déjà", {
name: "EmailAlreadyExistsError",
statusCode: 409,
}),
);
}
let territoire = "";
try {
Expand Down
16 changes: 14 additions & 2 deletions packages/frontend-usagers/src/pages/connexion/enregistrement.vue
Original file line number Diff line number Diff line change
Expand Up @@ -440,15 +440,27 @@ async function register() {
return navigateTo("/");
} catch (error) {
const statusCode = error.response?.status || error.statusCode || 0;
const body = error.data;
const codeError = body?.name;
log.w("Erreur lors de l'enregistrement :", error);

if (codeError === "EmailAlreadyExistsError") {
toaster.error({
titleTag: "h2",
description:
"Un compte existe déjà avec cette adresse mail. Veuillez vous connecter.",
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ux writing: pour cohérence avec les autres messages qui utilisent le terme "e-mail", modifier mail -> e-mail

});
return navigateTo("/");
}

if (statusCode === 500) {
toaster.error({
titleTag: "h2",
description:
"Une erreur technique est survenue, veuillez réessayer plus tard",
});
}
const body = error.data;
const codeError = body.name;

let description = "";
switch (codeError) {
case "UserAlreadyExists":
Expand Down