@@ -132,23 +132,40 @@ const isPrivilegedUser =
132132 securityStore .isAdmin || securityStore .isTeacher || securityStore .isHRM || securityStore .isSessionAdmin
133133
134134const allowCatalogueAccess = computed (() => {
135- if (isAnonymous) return platformConfigStore .getSetting (" catalog.course_catalog_published" ) !== " false"
136- if (isPrivilegedUser) return true
137- if (securityStore .isStudent )
135+ if (isAnonymous) {
136+ return platformConfigStore .getSetting (" catalog.course_catalog_published" ) !== " false"
137+ }
138+
139+ if (isPrivilegedUser) {
140+ return true
141+ }
142+
143+ if (securityStore .isStudent ) {
138144 return platformConfigStore .getSetting (" catalog.allow_students_to_browse_courses" ) !== " false"
145+ }
146+
139147 return false
140148})
141149
142- if (! allowCatalogueAccess .value ) {
143- if (! securityStore .user ? .id ) {
144- router .push ({ name: " Login" })
145- } else if (securityStore .isStudent ) {
146- router .push ({ name: " Home" })
147- } else {
148- router .push ({ name: " Index" })
150+ watch (allowCatalogueAccess, async (newValue ) => {
151+ if (true !== newValue) {
152+ return
149153 }
150- throw new Error (" Catalogue access denied by settings" )
151- }
154+
155+ if (! securityStore .isAuthenticated ) {
156+ await router .push ({ name: " Login" })
157+
158+ return
159+ }
160+
161+ if (securityStore .isStudent ) {
162+ await router .push ({ name: " Home" })
163+
164+ return
165+ }
166+
167+ await router .push ({ name: " Index" })
168+ })
152169
153170const currentUserId = securityStore .user ? .id ?? null
154171const status = ref (false )
0 commit comments