diff --git a/AuthService.cpp b/AuthService.cpp new file mode 100644 index 0000000..291bc1a --- /dev/null +++ b/AuthService.cpp @@ -0,0 +1,15 @@ +#include "AuthService.h" +#include + +User* AuthService::login(Database& db, + const std::string& username, + const std::string& password) { + auto users = db.getAllUsers(); + for (auto user : users) { + if (user->getUsername() == username) { + return user; + } + } + std::cout << "Erreur : utilisateur introuvable.\n"; + return nullptr; +} diff --git a/AuthService.h b/AuthService.h new file mode 100644 index 0000000..4d65d81 --- /dev/null +++ b/AuthService.h @@ -0,0 +1,15 @@ +#ifndef AUTHSERVICE_H +#define AUTHSERVICE_H + +#include "../database/Database.h" +#include "../models/User.h" +#include + +class AuthService { +public: + static User* login(Database& db, + const std::string& username, + const std::string& password); +}; + +#endif \ No newline at end of file diff --git a/ExportService.cpp b/ExportService.cpp new file mode 100644 index 0000000..a476332 --- /dev/null +++ b/ExportService.cpp @@ -0,0 +1,35 @@ +#include "ExportService.h" +#include +#include + +void ExportService::exportData(User* user) { + if (user == nullptr) { + std::cout << "Erreur : utilisateur invalide.\n"; + return; + } + + std::ofstream file("export.txt"); + if (!file.is_open()) { + std::cout << "Erreur lors de l'ouverture du fichier.\n"; + return; + } + + file << "===== EXPORT DES DONNEES =====\n"; + file << "Utilisateur : " << user->getUsername() << "\n\n"; + + if (user->getRole() == Role::ADMIN) { + file << "ROLE : ADMIN\n"; + file << "Accès complet aux étudiants, cours et notes.\n"; + } + else if (user->getRole() == Role::PROF) { + file << "ROLE : PROF\n"; + file << "Accès aux étudiants et modification des notes.\n"; + } + else if (user->getRole() == Role::STUDENT) { + file << "ROLE : STUDENT\n"; + file << "Accès uniquement à ses informations et notes.\n"; + } + + file.close(); + std::cout << "Export terminé avec succès.\n"; +} \ No newline at end of file diff --git a/ExportService.h b/ExportService.h new file mode 100644 index 0000000..4dc3c98 --- /dev/null +++ b/ExportService.h @@ -0,0 +1,11 @@ +#ifndef EXPORTSERVICE_H +#define EXPORTSERVICE_H + +#include "../models/User.h" + +class ExportService { +public: + static void exportData(User* user); +}; + +#endif \ No newline at end of file