UserData* UserController :: checkIn(std::string ID, std::string passwd) { Logging log("UserController :: checkIn",true); UserData* toReturn = findUser(ID); if(toReturn) { if(toReturn->Password() == passwd) return toReturn; else throw PasswordNotCorrectException((std::string)"password wrong!"); } else throw ItemNotFoundException((std::string)"user not exist!"); }
std::pair<std::string,std::string> UserController :: getDefaultUser() { Logging log("UserController :: getDefaultUser",true); std::ifstream input(__defaultUserFile); std::string ID,passwd; int rem; if(input) { input >> ID >> rem; UserData* defaultUser = findUser(ID); if(defaultUser) { log << "INFO now default user " << defaultUser->Name() << std::endl; if(rem) { log << "INFO remember password." << std::endl; passwd = defaultUser->Password(); } } else ID=""; } return std::make_pair(ID,passwd); }