mirror of
https://github.com/kerberos-io/agent.git
synced 2026-10-19 17:38:25 +00:00
57 lines
1.1 KiB
JavaScript
57 lines
1.1 KiB
JavaScript
import API from './api';
|
|
|
|
export function doLogin(username, password, onSuccess, onError) {
|
|
API.post('login', {
|
|
username,
|
|
password,
|
|
})
|
|
.then((res) => {
|
|
if (res.status !== 200) {
|
|
throw new Error(res.data);
|
|
}
|
|
return res.data;
|
|
})
|
|
.then((data) => {
|
|
onSuccess(data);
|
|
})
|
|
.catch((error) => {
|
|
if (error.response) {
|
|
onError(error.response.data);
|
|
} else {
|
|
onError({
|
|
message: "Couldn't connect to the API",
|
|
});
|
|
}
|
|
});
|
|
}
|
|
|
|
export function doCheckIfInstalled(onSuccess, onError) {
|
|
API.get('installed')
|
|
.then((res) => {
|
|
if (res.status !== 200) {
|
|
throw new Error(res.data);
|
|
}
|
|
return res.data;
|
|
})
|
|
.then((data) => {
|
|
onSuccess(data);
|
|
})
|
|
.catch((error) => {
|
|
if (error.response) {
|
|
onError(error.response.data);
|
|
} else {
|
|
onError({
|
|
message: "Couldn't connect to the API",
|
|
});
|
|
}
|
|
});
|
|
}
|
|
|
|
/* export function doAuth(onSuccess, onError) {
|
|
|
|
}
|
|
|
|
export function doRefreshToken(onSuccess, onError) {
|
|
|
|
} */
|