Commit 8156646d by Nabiilah Putri Safa

edit middleware

1 parent 9b3cf799
export default defineNuxtRouteMiddleware(to => { import { defineNuxtRouteMiddleware, navigateTo } from "nuxt/app"
return undefined import { useKeycloakStore } from "~/@core/stores/keycloakStore"
export default defineNuxtRouteMiddleware((to) => {
const keycloakStore = useKeycloakStore()
if (process.client) {
const isLoginPage = to.path === '/login'
// Jika belum login dan bukan sedang menuju halaman login, redirect ke login
if (!keycloakStore.authenticated && !isLoginPage) {
return navigateTo('/login')
}
// Kalau sudah login dan mencoba ke /login, bisa arahkan ke dashboard atau home
if (keycloakStore.authenticated && isLoginPage) {
return navigateTo('/') // atau ke '/dashboard' misalnya
}
}
}) })
...@@ -413,7 +413,7 @@ function openDialog() { ...@@ -413,7 +413,7 @@ function openDialog() {
</div> </div>
</VCardText> </VCardText>
<VCardText <!-- <VCardText
v-else v-else
class="d-flex align-bottom flex-sm-row flex-column justify-center gap-x-6" class="d-flex align-bottom flex-sm-row flex-column justify-center gap-x-6"
> >
...@@ -486,7 +486,7 @@ function openDialog() { ...@@ -486,7 +486,7 @@ function openDialog() {
</VBtn> </VBtn>
</div> </div>
</div> </div>
</VCardText> </VCardText> -->
</VCard> </VCard>
</template> </template>
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!