From 485316c5769bab3d582dcbcfc16b045e03e01e20 Mon Sep 17 00:00:00 2001 From: Anthony Debucquoy Date: Sun, 10 Mar 2024 23:30:18 +0100 Subject: [PATCH] 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 + }); } /**