Skip to content

Send and receive SMS messages using your Android phone programmatically via a simple HTTP API

577 B
Raw Blame
import { useAuthStore } from '../stores/auth'

export default defineNuxtRouteMiddleware(async (to: { path: string }) => {
  const authStore = useAuthStore()

  if (!authStore.authStateChanged) {
    await new Promise<void>((resolve) => {
      const stop = watch(
        () => authStore.authStateChanged,
        (changed) => {
          if (changed) {
            stop()
            resolve()
          }
        },
        { immediate: true },
      )
    })
  }

  if (authStore.authUser === null) {
    return navigateTo({ path: '/login', query: { to: to.path } })
  }
})