diff --git a/src/components/topic/CreateTopicForm.jsx b/src/components/topic/CreateTopicForm.jsx index e435e0cb171032bc2eafc738aff80584c8ecfd8b..3c93f1e25f49bbc02009dd82aa0a316dc4ab9231 100644 --- a/src/components/topic/CreateTopicForm.jsx +++ b/src/components/topic/CreateTopicForm.jsx @@ -5,9 +5,12 @@ import '../../styles/topic/CreateTopicForm.css'; import authHeader from '../../helpers/services/authHeader.service'; import { API_URL } from '../../config/keys'; import AuthService from '../../helpers/services/auth.service'; +import { loggedIn } from '../../helpers/services/loggedIn.service'; export default function CreateTopicForm(props) { - if (AuthService.getCurrentUser().data.role != "admin") { + const isAdmin = loggedIn ? AuthService.getCurrentUser().data.role : "unregistered"; + + if (isAdmin != "admin") { props.history.push("/page/1") } diff --git a/src/components/topic/Topic.jsx b/src/components/topic/Topic.jsx index 2ff714d2deaba6e9f772280858b6e97b7ab0cd88..7147f0d9de8702bca93e79252a0be33afd648dd5 100644 --- a/src/components/topic/Topic.jsx +++ b/src/components/topic/Topic.jsx @@ -13,7 +13,7 @@ export default function Topic(props) { const { params } = props.match; const currentPage = params.pageNumber; const topicParam = params.topic; - const isAdmin = AuthService.getCurrentUser().data.role + const isAdmin = loggedIn ? AuthService.getCurrentUser().data.role : "unregistered"; const [threads, setThreads] = useState([]); const [totalItems, setTotalItems] = useState(0);