import api from './api';

/**
 * Request password reset token
 */
export const requestPasswordReset = async (username) => {
  try {
    const response = await api.post('/auth/forgot-password', { username });
    return {
      success: true,
      message: response.data.message,
      token: response.data.token // Only in development
    };
  } catch (error) {
    return {
      success: false,
      message: error.response?.data?.message || 'Fehler bei der Passwort-Reset-Anfrage'
    };
  }
};

/**
 * Reset password with token
 */
export const resetPassword = async (token, newPassword) => {
  try {
    const response = await api.post('/auth/reset-password', { token, newPassword });
    return {
      success: true,
      message: response.data.message
    };
  } catch (error) {
    return {
      success: false,
      message: error.response?.data?.message || 'Fehler beim Zurücksetzen des Passworts'
    };
  }
};
