import { Request, Response } from 'express';
import { AuthenticatedRequest } from '../middleware/auth';
import logger from '../utils/logger';

export interface RegisterRequest extends Request {
  body: {
    email: string;
    name: string;
    password: string;
  };
}

export interface LoginRequest extends Request {
  body: {
    email: string;
    password: string;
  };
}

export interface RefreshTokenRequest extends Request {
  body: {
    refreshToken: string;
  };
}

/**
 * DEPRECATED: Legacy auth controller
 * All auth functions are now handled by Firebase Auth
 */
export const authController = {
  async register(_req: RegisterRequest, res: Response): Promise<void> {
    logger.warn('Legacy register endpoint is deprecated. Use Firebase Auth instead.');
    res.status(501).json({
      success: false,
      message: 'Legacy registration is disabled. Use Firebase Auth instead.',
      error: 'DEPRECATED_ENDPOINT'
    });
  },

  async login(_req: LoginRequest, res: Response): Promise<void> {
    logger.warn('Legacy login endpoint is deprecated. Use Firebase Auth instead.');
    res.status(501).json({
      success: false,
      message: 'Legacy login is disabled. Use Firebase Auth instead.',
      error: 'DEPRECATED_ENDPOINT'
    });
  },

  async refreshToken(_req: RefreshTokenRequest, res: Response): Promise<void> {
    logger.warn('Legacy refresh token endpoint is deprecated. Use Firebase Auth instead.');
    res.status(501).json({
      success: false,
      message: 'Legacy token refresh is disabled. Use Firebase Auth instead.',
      error: 'DEPRECATED_ENDPOINT'
    });
  },

  async logout(_req: AuthenticatedRequest, res: Response): Promise<void> {
    logger.warn('Legacy logout endpoint is deprecated. Use Firebase Auth instead.');
    res.status(501).json({
      success: false,
      message: 'Legacy logout is disabled. Use Firebase Auth instead.',
      error: 'DEPRECATED_ENDPOINT'
    });
  },

  async getProfile(_req: AuthenticatedRequest, res: Response): Promise<void> {
    logger.warn('Legacy profile endpoint is deprecated. Use Firebase Auth instead.');
    res.status(501).json({
      success: false,
      message: 'Legacy profile access is disabled. Use Firebase Auth instead.',
      error: 'DEPRECATED_ENDPOINT'
    });
  },

  async updateProfile(_req: AuthenticatedRequest, res: Response): Promise<void> {
    logger.warn('Legacy profile update endpoint is deprecated. Use Firebase Auth instead.');
    res.status(501).json({
      success: false,
      message: 'Legacy profile updates are disabled. Use Firebase Auth instead.',
      error: 'DEPRECATED_ENDPOINT'
    });
  },

  async changePassword(_req: AuthenticatedRequest, res: Response): Promise<void> {
    logger.warn('Legacy password change endpoint is deprecated. Use Firebase Auth instead.');
    res.status(501).json({
      success: false,
      message: 'Legacy password changes are disabled. Use Firebase Auth instead.',
      error: 'DEPRECATED_ENDPOINT'
    });
  },

  async deleteAccount(_req: AuthenticatedRequest, res: Response): Promise<void> {
    logger.warn('Legacy account deletion endpoint is deprecated. Use Firebase Auth instead.');
    res.status(501).json({
      success: false,
      message: 'Legacy account deletion is disabled. Use Firebase Auth instead.',
      error: 'DEPRECATED_ENDPOINT'
    });
  },

  async verifyEmail(_req: Request, res: Response): Promise<void> {
    logger.warn('Legacy email verification endpoint is deprecated. Use Firebase Auth instead.');
    res.status(501).json({
      success: false,
      message: 'Legacy email verification is disabled. Use Firebase Auth instead.',
      error: 'DEPRECATED_ENDPOINT'
    });
  },

  async requestPasswordReset(_req: Request, res: Response): Promise<void> {
    logger.warn('Legacy password reset endpoint is deprecated. Use Firebase Auth instead.');
    res.status(501).json({
      success: false,
      message: 'Legacy password reset is disabled. Use Firebase Auth instead.',
      error: 'DEPRECATED_ENDPOINT'
    });
  },

  async resetPassword(_req: Request, res: Response): Promise<void> {
    logger.warn('Legacy password reset endpoint is deprecated. Use Firebase Auth instead.');
    res.status(501).json({
      success: false,
      message: 'Legacy password reset is disabled. Use Firebase Auth instead.',
      error: 'DEPRECATED_ENDPOINT'
    });
  }
};