Merge branch 'master' into Max/Backend/Curriculum
This commit is contained in:
@ -15,16 +15,22 @@ export async function createRegister(){
|
||||
|
||||
/**
|
||||
* list all register request in a list of Objects
|
||||
*/
|
||||
export async function getRegisters(){
|
||||
return restGet("/requests/register")
|
||||
}
|
||||
|
||||
/**
|
||||
* Get info on a particular registering request
|
||||
* Shall return a list of
|
||||
* - id
|
||||
* - type
|
||||
* - lastName
|
||||
* - firstName
|
||||
* - address
|
||||
* - country
|
||||
* - birthdate
|
||||
* - email
|
||||
* - cursus
|
||||
* - degree
|
||||
*/
|
||||
export async function getRegisters(id){
|
||||
return restGet("/request/register/" + id);
|
||||
if(id != null)
|
||||
return restGet("/request/register/" + id);
|
||||
return restGet("/request/register")
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -4,8 +4,57 @@ 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 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, imageId){
|
||||
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 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, role, imageId){
|
||||
return restPost("/user", {
|
||||
firstname: firstname,
|
||||
lastname: lastname,
|
||||
birthDate: birthDate,
|
||||
password: password,
|
||||
email: email,
|
||||
address: address,
|
||||
country: country,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -11,6 +11,11 @@ export async function restPost(endPoint, data) {
|
||||
return await _rest(endPoint, {method: "POST", credentials: 'include', body: JSON.stringify(data)});
|
||||
}
|
||||
|
||||
export async function restPostFile(endPoint, file){
|
||||
let headers = new Headers();
|
||||
return await _rest(endPoint, {method: "POST", credentials: 'include', body: file, headers: headers });
|
||||
}
|
||||
|
||||
export async function restDelete(endPoint, data) {
|
||||
return await _rest(endPoint, {method: "DELETE", credentials: 'include', body: JSON.stringify(data)});
|
||||
}
|
||||
@ -35,13 +40,14 @@ async function _rest(endPoint, config){
|
||||
'Authorization': session_token,
|
||||
'Content-Type': 'application/json',
|
||||
});
|
||||
config['headers'] = headers;
|
||||
config['headers'] = config['headers'] == null ? headers : config['headers'];
|
||||
return toast.promise(fetch(restURL + endPoint, config),
|
||||
{
|
||||
pending: config['pending'] != null ? config['pending'] : 'pending',
|
||||
error: config['error'] != null ? config['error'] : 'Network Failure...',
|
||||
success: config['success'] != null ? config['success'] : {render(res){
|
||||
return res.ok ? "Success" : "error";
|
||||
console.log(res);
|
||||
return res.data.ok ? "Success" : "error";
|
||||
}},
|
||||
})
|
||||
.then( e => e.json()).catch( e => e );
|
||||
|
11
frontend/src/rest/uploads.js
Normal file
11
frontend/src/rest/uploads.js
Normal file
@ -0,0 +1,11 @@
|
||||
import { restPostFile } from '@/rest/restConsumer.js'
|
||||
|
||||
|
||||
/**
|
||||
* Upload a file to the server and return the url of this image
|
||||
*/
|
||||
export async function uploadProfilePicture(file){
|
||||
const formData = new FormData();
|
||||
formData.append("file", file[0]);
|
||||
return restPostFile("/upload/ProfilePicture", formData)
|
||||
}
|
Reference in New Issue
Block a user