1
0
Fork 0
mirror of synced 2024-09-19 02:39:37 +12:00
budibase/packages/frontend-core/src/api/auth.js

36 lines
734 B
JavaScript

export const buildAuthEndpoints = API => ({
/**
* Performs a log in request.
*/
logIn: async ({ email, password }) => {
if (!email) {
return API.error("Please enter your email")
}
if (!password) {
return API.error("Please enter your password")
}
return await API.post({
url: "/api/global/auth",
body: {
username: email,
password,
},
})
},
/**
* Logs the user out and invalidates their session.
*/
logOut: async () => {
return await API.post({
url: "/api/global/auth/logout",
})
},
/**
* Fetches the currently logged in user object
*/
fetchSelf: async () => {
return await API.get({ url: "/api/self" })
},
})