2024-10-15 19:49:44 -04:00
|
|
|
import { ENV_VARIABLES } from '../constants';
|
|
|
|
|
|
|
|
|
|
class AuthService {
|
|
|
|
|
|
|
|
|
|
private BASE_URL: string;
|
|
|
|
|
|
|
|
|
|
constructor() {
|
|
|
|
|
this.BASE_URL = ENV_VARIABLES.VITE_BACKEND_URL;
|
|
|
|
|
}
|
|
|
|
|
|
2024-10-18 17:40:28 -04:00
|
|
|
private constructRequestUrl(endpoint: string): string {
|
|
|
|
|
return `${this.BASE_URL}/api${endpoint}`;
|
|
|
|
|
}
|
|
|
|
|
|
2024-10-15 19:49:44 -04:00
|
|
|
async fetchAuthData(){
|
|
|
|
|
try {
|
2024-10-18 17:40:28 -04:00
|
|
|
const response = await fetch(this.constructRequestUrl('/auth/getActiveAuth'));
|
2024-10-15 19:49:44 -04:00
|
|
|
const data = await response.json();
|
|
|
|
|
return data.authActive;
|
|
|
|
|
} catch (error) {
|
|
|
|
|
console.error('Erreur lors de la récupération des données d\'auth:', error);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const authService = new AuthService();
|
|
|
|
|
export default authService;
|