import { d as defineEventHandler, g as getCookie, a as deleteCookie } from '../../../nitro/nitro.mjs';
import { a as getUserFromToken } from '../../../_/auth.mjs';
import 'node:http';
import 'node:https';
import 'node:events';
import 'node:buffer';
import 'node:fs';
import 'node:path';
import 'node:crypto';
import 'node:url';
import 'bcryptjs';
import 'jsonwebtoken';
import 'fs';
import 'path';
import '../../../_/encryption.mjs';
import 'crypto';

const status_get = defineEventHandler(async (event) => {
  try {
    const token = getCookie(event, "auth_token");
    if (!token) {
      return {
        isLoggedIn: false,
        user: null,
        role: null
      };
    }
    const user = await getUserFromToken(token);
    if (!user) {
      deleteCookie(event, "auth_token");
      return {
        isLoggedIn: false,
        user: null,
        role: null
      };
    }
    return {
      isLoggedIn: true,
      user: {
        id: user.id,
        email: user.email,
        name: user.name,
        role: user.role
      },
      role: user.role
    };
  } catch (error) {
    console.error("Auth-Status-Fehler:", error);
    return {
      isLoggedIn: false,
      user: null,
      role: null
    };
  }
});

export { status_get as default };
//# sourceMappingURL=status.get.mjs.map
