diff --git a/src/Components/Public/ProfileList.js b/src/Components/Public/ProfileList.js index 13231dd1..7ea2d220 100644 --- a/src/Components/Public/ProfileList.js +++ b/src/Components/Public/ProfileList.js @@ -15,6 +15,7 @@ export default function Memberlist() { const [isLoading, setIsLoading ] = useState(false); const [isError, setIsError ] = useState(false); + const [isForbidden, setIsForbidden ] = useState(false); const [currentPage, setCurrentPage] = useState(1); const [membersPerPage, setMembersPerPage] = useState(25); @@ -34,15 +35,24 @@ export default function Memberlist() { fetch(`${API_URL}s/${sysID}/members`,{ method: 'GET', - }).then ( res => res.json() + }).then ( res => { + if (res.status === 403) { + throw new Error('Access denied!'); + } + res.json() + } ).then (data => { setMembers(data) setIsLoading(false); }) - .catch (error => { + .catch (error => { + if (error.message === 'Access denied!') { + setIsForbidden(true); + } else { console.log(error); setIsError(true); - setIsLoading(false); + } + setIsLoading(false); }) }, [sysID]) @@ -206,7 +216,7 @@ export default function Memberlist() { { isLoading ? : isError ? - Error fetching members. : + Error fetching members. : isForbidden ? Member list is private. : <> {memberList}