From 485316c5769bab3d582dcbcfc16b045e03e01e20 Mon Sep 17 00:00:00 2001 From: Anthony Debucquoy Date: Sun, 10 Mar 2024 23:30:18 +0100 Subject: [PATCH 1/2] Register API and form optimization Made the register api following the backend refactored the register form for more ergonomy --- frontend/src/Apps/Login.vue | 24 ++++++---------- frontend/src/rest/Users.js | 57 +++++++++++++++++++++++++++++++++++-- 2 files changed, 64 insertions(+), 17 deletions(-) diff --git a/frontend/src/Apps/Login.vue b/frontend/src/Apps/Login.vue index 5f053ab..a06a5ce 100644 --- a/frontend/src/Apps/Login.vue +++ b/frontend/src/Apps/Login.vue @@ -5,23 +5,16 @@ const loginPage= ref(true) const page = ref(0) - const emailID=ref("") - const passwordIN=ref("") - - const submitValue= ref(i18n("login.guest.submit")) const surname=ref("") const firstname=ref("") - const passwordOUT=ref("") + const password=ref("") const passwordConfirm=ref("") const birthday=ref("") - const emailOUT=ref("") + const email=ref("") const address=ref("") const country=ref("") const cursus=ref("") - const loginInfos = [{_emailID:emailID},{_passwordIN:passwordIN}] - const registerInfos= [{_surname:surname},{_firstname:firstname},{_birthday:birthday},{_passwordOUT:passwordOUT}, - {_passwordConfirm:passwordConfirm},{_emailOUT:emailOUT},{_address:address},{_country:country},{_cursus:cursus}] @@ -31,17 +24,17 @@
-
+

{{i18n("login.guest.signin")}}

ID / {{i18n("login.guest.email")}}

- +

{{i18n("login.guest.password")}}

- +
- +

{{i18n("login.guest.welcome")}}

@@ -72,11 +65,12 @@

{{i18n("login.guest.password")}}

- +

{{i18n("login.guest.confirm")}} {{i18n("login.guest.password")}}

+
@@ -90,7 +84,7 @@

{{i18n("login.guest.email")}}

- +

{{i18n("login.guest.address")}}

diff --git a/frontend/src/rest/Users.js b/frontend/src/rest/Users.js index cca662d..29e1b1f 100644 --- a/frontend/src/rest/Users.js +++ b/frontend/src/rest/Users.js @@ -4,8 +4,61 @@ export async function login(user, pass, exp){ return restPost("/login", {identifier: user, password: pass, expirationDate: exp}); } -export async function register(user, pass, mail){ - return restPost("/user", {name: user, password: pass, mail: mail}); +/** + * Register a user (tokenless) + * + * @param data object containing info about the user + * + * - firstname + * - lastname + * - birthdate + * - password + * - mail + * - address + * - country + * - cursus + */ +export async function register(firstname, lastname, birthDate, password, email, address, country, cursus){ + return restPost("/register", { + firstname: firstname, + lastname: lastname, + birthDate: birthDate, + password: password, + email: email, + address: address, + country: country, + cursus: cursus + }); +} + +/** + * Register a user (by secretary) + * + * @param data object containing info about the user + * + * - firstname + * - lastname + * - birthdate + * - password + * - mail + * - address + * - country + * - cursus + * + * PS: the password is not is not required as it is generated by the backend and sent to the user + * by mail. it's up to the user to change it if he cares about security + */ +export async function createUser(firstname, lastname, birthDate, email, address, country, cursus, role){ + return restPost("/user", { + firstname: firstname, + lastname: lastname, + birthDate: birthDate, + password: password, + email: email, + address: address, + country: country, + cursus:cursus + }); } /** -- 2.48.1 From e6dd0a8995e5a621c0df70f585c06dd62d605ca1 Mon Sep 17 00:00:00 2001 From: Anthony Debucquoy Date: Wed, 13 Mar 2024 13:18:24 +0100 Subject: [PATCH 2/2] fix --- frontend/src/rest/Users.js | 42 +++++++++++++++++--------------------- 1 file changed, 19 insertions(+), 23 deletions(-) diff --git a/frontend/src/rest/Users.js b/frontend/src/rest/Users.js index 29e1b1f..381bcb3 100644 --- a/frontend/src/rest/Users.js +++ b/frontend/src/rest/Users.js @@ -7,18 +7,17 @@ export async function login(user, pass, exp){ /** * Register a user (tokenless) * - * @param data object containing info about the user - * - * - firstname - * - lastname - * - birthdate - * - password - * - mail - * - address - * - country - * - cursus + * @param firstname + * @param lastname + * @param birthdate + * @param password + * @param mail + * @param address + * @param country + * @param cursus + * @param imageId id of the image in database returned when uploaded */ -export async function register(firstname, lastname, birthDate, password, email, address, country, cursus){ +export async function register(firstname, lastname, birthDate, password, email, address, country, cursus, imageId){ return restPost("/register", { firstname: firstname, lastname: lastname, @@ -34,21 +33,19 @@ export async function register(firstname, lastname, birthDate, password, email, /** * Register a user (by secretary) * - * @param data object containing info about the user - * - * - firstname - * - lastname - * - birthdate - * - password - * - mail - * - address - * - country - * - cursus + * @param firstname + * @param lastname + * @param birthdate + * @param password + * @param mail + * @param address + * @param country + * @param imageId id of the image in database returned when uploaded * * PS: the password is not is not required as it is generated by the backend and sent to the user * by mail. it's up to the user to change it if he cares about security */ -export async function createUser(firstname, lastname, birthDate, email, address, country, cursus, role){ +export async function createUser(firstname, lastname, birthDate, email, address, country, role, imageId){ return restPost("/user", { firstname: firstname, lastname: lastname, @@ -57,7 +54,6 @@ export async function createUser(firstname, lastname, birthDate, email, address, email: email, address: address, country: country, - cursus:cursus }); } -- 2.48.1