You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

14 lines
280 B
JavaScript

import {useEffect} from 'react'
import Router from 'next/router'
import useUser from './useUser'
export default function useAccountRedirect(){
const user = useUser()
if(user && user.is_admin) return;
const err = new Error("Unauthorized")
err.status = 401
throw err
}