Exemplo n.º 1
0
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!");
}
Exemplo n.º 2
0
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);
}