More feedback on account creation, bugfix on account creation
This commit is contained in:
@@ -3,34 +3,83 @@ import { AccountModel } from "../models/user/accountModel"
|
||||
|
||||
const BASE_URL = "http://localhost:3000/accounts"
|
||||
|
||||
export async function fetchAllAccounts() {
|
||||
return await axios.get(BASE_URL)
|
||||
/**
|
||||
* Fetch all accounts from server
|
||||
*
|
||||
* @param token Validation token of current logged in user. User needs to have the right privileges
|
||||
*
|
||||
* @returns Response from server with list of all account body
|
||||
*/
|
||||
export async function fetchAllAccounts(token: string) {
|
||||
return await axios.get(BASE_URL, {
|
||||
headers: {
|
||||
"Authorization": token
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
export async function login(username: string, password: string) {
|
||||
return await axios.get(BASE_URL + "/login?username=" + username + "&password=" + password)
|
||||
/**
|
||||
* Start the login process
|
||||
*
|
||||
* @param username Username of the account
|
||||
* @param password Password of the account
|
||||
*
|
||||
* @returns Response from server with token body
|
||||
*/
|
||||
export async function getLogin(username: string, password: string) {
|
||||
return await axios.get(BASE_URL + "/account/login?username=" + username + "&password=" + password)
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get all data about a single account
|
||||
*
|
||||
* @param token Validation token
|
||||
*
|
||||
* @returns Response from server with account body
|
||||
*/
|
||||
export async function getAccount(token: string) {
|
||||
return await axios.get(BASE_URL + "/account", {
|
||||
return await axios.get(BASE_URL + "/account/data", {
|
||||
headers: {
|
||||
"Authorization": token
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* Register a new account in servers database
|
||||
*
|
||||
* @param account Account data for new dataset
|
||||
*
|
||||
* @returns Response from server
|
||||
*/
|
||||
export async function registerAccount(account: AccountModel) {
|
||||
return await axios.post(BASE_URL, account)
|
||||
return await axios.post(BASE_URL + "/account", account)
|
||||
}
|
||||
|
||||
/**
|
||||
* Update data of an account
|
||||
*
|
||||
* @param account Account data to update
|
||||
* @param token Validation token
|
||||
*
|
||||
* @returns Response from server
|
||||
*/
|
||||
export async function updateAccount(account: AccountModel, token: string) {
|
||||
return await axios.patch(BASE_URL, account, {
|
||||
return await axios.patch(BASE_URL + "/account", account, {
|
||||
headers: {
|
||||
"Authorization": token
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete an account in servers database
|
||||
*
|
||||
* @param account Account to delete
|
||||
*
|
||||
* @returns Response from server
|
||||
*/
|
||||
export async function deleteAccount(account: AccountModel) {
|
||||
return await axios.delete(BASE_URL + "/" + account.id)
|
||||
return await axios.delete(BASE_URL + "/account/" + account.id)
|
||||
}
|
||||
Reference in New Issue
Block a user