UNPKG

nuxt-users

Version:

A comprehensive user management module for Nuxt 3 and Nuxt 4 applications with authentication, authorization, database support, and CLI tools

18 lines (17 loc) 518 B
import { getCurrentUserFromToken } from "../utils/user.js"; export const useServerAuth = () => { const getCurrentUser = async (event) => { const { useRuntimeConfig } = await import("#imports"); const { getCookie } = await import("h3"); const token = getCookie(event, "auth_token"); if (!token) { return null; } const { nuxtUsers } = useRuntimeConfig(); const user = await getCurrentUserFromToken(token, nuxtUsers, false); return user; }; return { getCurrentUser }; };