fleet/frontend/kolide/index.js
Mike Stone beda051de2 Show invited users (#297)
* Adds loadAll action to redux entity config

* API Client get invites

* Add invites to the user management page

* Updates user block styles on user management page

* Submit modal form on enter

* Modify details form styles

* Enter submits edit user form

* Removes unused admin dashboard page

* API Client - revoke invites

* Delete invite entities in redux

* Revoke invites from admin manage users page

* Show success flash message after user invite is revoked
2016-10-14 17:08:57 -04:00

85 lines
2.2 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; });
}
getInvites = () => {
const { INVITES } = endpoints;
return this.authenticatedGet(this.endpoint(INVITES))
.then(response => { return response.invites; });
}
getUsers = () => {
const { USERS } = endpoints;
return this.authenticatedGet(this.endpoint(USERS))
.then(response => { return response.users; });
}
inviteUser = (formData) => {
const { INVITES } = endpoints;
return this.authenticatedPost(this.endpoint(INVITES), JSON.stringify(formData))
.then(response => { return response.invite; });
}
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));
}
revokeInvite = ({ entityID }) => {
const { INVITES } = endpoints;
const endpoint = `${this.endpoint(INVITES)}/${entityID}`;
return this.authenticatedDelete(endpoint);
}
updateUser = (user, formData) => {
const { USERS } = endpoints;
const updateUserEndpoint = `${this.baseURL}${USERS}/${user.id}`;
return this.authenticatedPatch(updateUserEndpoint, JSON.stringify(formData))
.then(response => { return response.user; });
}
}
export default new Kolide();