Téléverser les fichiers vers "/"
This commit is contained in:
15
AuthService.cpp
Normal file
15
AuthService.cpp
Normal file
@@ -0,0 +1,15 @@
|
||||
#include "AuthService.h"
|
||||
#include <iostream>
|
||||
|
||||
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;
|
||||
}
|
||||
15
AuthService.h
Normal file
15
AuthService.h
Normal file
@@ -0,0 +1,15 @@
|
||||
#ifndef AUTHSERVICE_H
|
||||
#define AUTHSERVICE_H
|
||||
|
||||
#include "../database/Database.h"
|
||||
#include "../models/User.h"
|
||||
#include <string>
|
||||
|
||||
class AuthService {
|
||||
public:
|
||||
static User* login(Database& db,
|
||||
const std::string& username,
|
||||
const std::string& password);
|
||||
};
|
||||
|
||||
#endif
|
||||
35
ExportService.cpp
Normal file
35
ExportService.cpp
Normal file
@@ -0,0 +1,35 @@
|
||||
#include "ExportService.h"
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
|
||||
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";
|
||||
}
|
||||
11
ExportService.h
Normal file
11
ExportService.h
Normal file
@@ -0,0 +1,11 @@
|
||||
#ifndef EXPORTSERVICE_H
|
||||
#define EXPORTSERVICE_H
|
||||
|
||||
#include "../models/User.h"
|
||||
|
||||
class ExportService {
|
||||
public:
|
||||
static void exportData(User* user);
|
||||
};
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user