Anthony Debucquoy
f52cb31189
Reviewed-on: PGL/Clyde#88 Reviewed-by: Wal <karpinskiwal@gmail.com> Reviewed-by: Maxime <231026@umons.ac.be> Reviewed-by: LeoMoulin <leomoulin125@gmail.com> Co-authored-by: Anthony Debucquoy <debucquoy.anthony@gmail.com> Co-committed-by: Anthony Debucquoy <debucquoy.anthony@gmail.com>
71 lines
1.4 KiB
JavaScript
71 lines
1.4 KiB
JavaScript
import { restGet, restPost } from './restConsumer.js'
|
|
|
|
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});
|
|
}
|
|
|
|
/**
|
|
* get informations on a specific user.
|
|
* Leaving the id empty will return the user's value based on his token
|
|
* if the user is not authenticated. then an empty array should be returned
|
|
*/
|
|
export async function getUser(id){
|
|
const endpoint = "/user" + id != null ? "/" + id : "";
|
|
return restGet(endpoint);
|
|
}
|
|
|
|
/**
|
|
* Alterable datas of user.
|
|
* usage by secretary
|
|
*
|
|
* @param id regno of the user
|
|
* @param data data to change
|
|
*
|
|
* - lastName
|
|
* - firstName
|
|
* - birthDate
|
|
* - role
|
|
* - email
|
|
* - photo
|
|
* - Adress
|
|
*/
|
|
export async function alterUser(id, data){
|
|
return restPatch("/user/" + id, data);
|
|
}
|
|
|
|
/**
|
|
* Reserved for secretary roles. Allow to list all user on the plateform
|
|
*/
|
|
export async function getAllUsers(){
|
|
return restGet("/users");
|
|
}
|
|
|
|
|
|
/**
|
|
* Get informations about yourself
|
|
* - RegNo
|
|
* - FirstName / LastName
|
|
* - email
|
|
* - adressId (?)
|
|
* - birthDate
|
|
* - role
|
|
*/
|
|
export async function getSelf(){
|
|
return restGet("/user");
|
|
}
|
|
|
|
/**
|
|
* Alterable datas are
|
|
* - email
|
|
* - photo
|
|
* - Adress
|
|
* - Password
|
|
*/
|
|
export async function alterSelf(data){
|
|
return restPatch("/user", data);
|
|
}
|