You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
proiectPOO/User.cpp

62 lines
1.2 KiB

//
// Created by ioachim on 17.05.2025.
//
#include "User.h"
#include "Document.h"
void User::addDocument(Document* doc) {
Dosar[doc->getID()] = doc;
}
void User::removeDocument(std::string _id) {
Dosar.erase(_id);
}
User::~User() {
}
User::User(const std::string& id, const std::string& _name, const std::string& password) : userID(id), nume(_name), passHash(hashString(password)), Dosar() {
userID = id;
nume = _name;
passHash = hashString(password);
}
User& User::operator=(const User& frate) {
if(this != &frate) {
userID = frate.userID;
nume = frate.nume;
passHash = frate.passHash;
Dosar = frate.Dosar;
}
return *this;
}
std::ostream& operator <<(std::ostream& os, const User& user){
os << "ID: " << user.userID << "\nNume: " << user.nume << "\nDosar: ";
os << "\n";
return os;
}
bool User::tryLogin(std::string _pass) {
if (hashString(_pass) == passHash) {
return true;
}
return false;
}
bool User::changePassword(std::string _pass, std::string _newpass) {
if (hashString(_pass) == passHash) {
passHash = hashString(_pass);
return true;
}
return false;
}
std::string User::getName() {
return "";
}