mirror of
https://github.com/empayre/fleet.git
synced 2024-11-07 09:18:59 +00:00
23bed0c56d
* Adds call to API client to get config * Saves config in redux state
63 lines
1.6 KiB
JavaScript
63 lines
1.6 KiB
JavaScript
import Base from './base';
|
|
import endpoints from './endpoints';
|
|
|
|
class Kolide extends Base {
|
|
forgotPassword ({ email }) {
|
|
const { FORGOT_PASSWORD } = endpoints;
|
|
const forgotPasswordEndpoint = this.baseURL + FORGOT_PASSWORD;
|
|
|
|
return this.post(forgotPasswordEndpoint, JSON.stringify({ email }));
|
|
}
|
|
|
|
getConfig = () => {
|
|
const { CONFIG } = endpoints;
|
|
|
|
return this.authenticatedGet(this.endpoint(CONFIG))
|
|
.then(response => { return response.org_info; });
|
|
}
|
|
|
|
getUsers = () => {
|
|
const { USERS } = endpoints;
|
|
|
|
return this.authenticatedGet(this.endpoint(USERS))
|
|
.then(response => { return response.users; });
|
|
}
|
|
|
|
loginUser ({ username, password }) {
|
|
const { LOGIN } = endpoints;
|
|
const loginEndpoint = this.baseURL + LOGIN;
|
|
|
|
return this.post(loginEndpoint, JSON.stringify({ username, password }));
|
|
}
|
|
|
|
logout () {
|
|
const { LOGOUT } = endpoints;
|
|
const logoutEndpoint = this.baseURL + LOGOUT;
|
|
|
|
return this.authenticatedPost(logoutEndpoint);
|
|
}
|
|
|
|
me () {
|
|
const { ME } = endpoints;
|
|
const meEndpoint = this.baseURL + ME;
|
|
|
|
return this.authenticatedGet(meEndpoint);
|
|
}
|
|
|
|
resetPassword (formData) {
|
|
const { RESET_PASSWORD } = endpoints;
|
|
const resetPasswordEndpoint = this.baseURL + RESET_PASSWORD;
|
|
|
|
return this.post(resetPasswordEndpoint, JSON.stringify(formData));
|
|
}
|
|
|
|
updateUser = (user, formData) => {
|
|
const { USERS } = endpoints;
|
|
const updateUserEndpoint = `${this.baseURL}${USERS}/${user.id}`;
|
|
|
|
return this.authenticatedPatch(updateUserEndpoint, JSON.stringify(formData));
|
|
}
|
|
}
|
|
|
|
export default new Kolide();
|