Add several endpoints
This commit is contained in:
1 parent
5beb0684a7
commit
f78e5ca94c
5 files changed
+29
-9
No files matched your search
@@ -52,10 +52,7 @@ const TeamPanel = () => {
|
|||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const fetchTeam = async () => {
|
const fetchTeam = async () => {
|
||||||
try {
|
try {
|
||||||
const response = await axiosInstance.get("/auth/users", {
|
const response = await axiosInstance.getAllUsers(authToken);
|
||||||
headers: { Authorization: `Bearer ${authToken}` },
|
|
||||||
});
|
|
||||||
|
|
||||||
setMembers(response.data.data);
|
setMembers(response.data.data);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
createToast({
|
createToast({
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ const withAdminCheck = (WrappedComponent) => {
|
|||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
axiosInstance
|
axiosInstance
|
||||||
.get("/auth/users/admin")
|
.doesAdminExist()
|
||||||
.then((response) => {
|
.then((response) => {
|
||||||
if (response.data.data === true) {
|
if (response.data.data === true) {
|
||||||
navigate("/login");
|
navigate("/login");
|
||||||
|
|||||||
@@ -249,7 +249,7 @@ const Login = () => {
|
|||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
axiosInstance
|
axiosInstance
|
||||||
.get("/auth/users/admin")
|
.doesAdminExist()
|
||||||
.then((response) => {
|
.then((response) => {
|
||||||
if (response.data.data === false) {
|
if (response.data.data === false) {
|
||||||
navigate("/register");
|
navigate("/register");
|
||||||
|
|||||||
@@ -397,9 +397,7 @@ const Register = ({ isAdmin }) => {
|
|||||||
const fetchInvite = async () => {
|
const fetchInvite = async () => {
|
||||||
if (token !== undefined) {
|
if (token !== undefined) {
|
||||||
try {
|
try {
|
||||||
const res = await axiosInstance.post(`/auth/invite/verify`, {
|
const res = await axiosInstance.verifyInvitationToken(token);
|
||||||
token,
|
|
||||||
});
|
|
||||||
const { role, email } = res.data.data;
|
const { role, email } = res.data.data;
|
||||||
console.log(role);
|
console.log(role);
|
||||||
setForm({ ...form, email, role });
|
setForm({ ...form, email, role });
|
||||||
|
|||||||
@@ -151,4 +151,29 @@ axiosInstance.setNewPassword = async (recoveryToken, form) => {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// **********************************
|
||||||
|
// Check for admin user
|
||||||
|
// **********************************
|
||||||
|
axiosInstance.doesAdminExist = async () => {
|
||||||
|
return axiosInstance.get("/auth/users/admin");
|
||||||
|
};
|
||||||
|
|
||||||
|
// **********************************
|
||||||
|
// Get all users
|
||||||
|
// **********************************
|
||||||
|
axiosInstance.getAllUsers = async (authToken) => {
|
||||||
|
return axiosInstance.get("/auth/users", {
|
||||||
|
headers: { Authorization: `Bearer ${authToken}` },
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
// **********************************
|
||||||
|
// Verify Invitation Token
|
||||||
|
// **********************************
|
||||||
|
axiosInstance.verifyInvitationToken = async (token) => {
|
||||||
|
return axiosInstance.post(`/auth/invite/verify`, {
|
||||||
|
token,
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
export default axiosInstance;
|
export default axiosInstance;
|
||||||
Reference in new issue
Block a user