Ejemplo n.º 1
0
void LoginManager::processPasswordConfirmation(const QString& aLine, Client &aClient)
{
    auto account = getAccountOrDie(aClient);
    if(!account)
        return;
    QByteArray passwordBytes;
    passwordBytes.append(aLine);
    QString hash = QString(QCryptographicHash::hash(passwordBytes, QCryptographicHash::Md5).toHex());
    if(account->getPasswordHash() != hash)
    {
        aClient.printRawLine("Passwords do not match. Try again.");
        aClient.printRawLine("Enter a password for this account: ");
        state_ = ELoginStateNewPassword;
        return;
    }
    //passwords match, ok
    //creating a new character now
    account->confirmCreation();
    auto newCharacter = world::World::instance()->objectFactory()->createPtr<Person>(Person::TYPE);
	newCharacter->putInDefaultRoom();
	account->addCharacter(newCharacter->uid());	
    aClient.setState(EClientStateNormal);
    aClient.linkToPerson(newCharacter);
    auto room = newCharacter->getRoom();
    if(room)//first look around
        room->printDescription(*(newCharacter.get()), aClient);
}
Ejemplo n.º 2
0
 void SecretsManager::setMasterPassword(const QString &masterPassword) {
     if (!masterPassword.isEmpty()) {
         m_EncodedMasterPassword = encodeText(masterPassword, m_PasswordForMasterPassword);
         m_MasterPasswordHash = getPasswordHash(masterPassword);
     } else {
         m_EncodedMasterPassword.clear();
         m_MasterPasswordHash.clear();
     }
 }
Ejemplo n.º 3
0
void LoginManager::processPasswordState(const QString& aLine, Client &aClient)
{
    auto account = getAccountOrDie(aClient);
    if(!account)
        return;
    //aLine is a password
    QByteArray passwordBytes;
    passwordBytes.append(aLine);
    QString hash = QString(QCryptographicHash::hash(passwordBytes,QCryptographicHash::Md5).toHex());
    if(account->getPasswordHash() != hash)
    {
        aClient.printRawLine("Wrong password. Disconnecting...");
        aClient.setState(EClientStateQuit);
        return;
    }
    //password is correct
    account->confirmCreation();
    aClient.printRawLine("Password is correct. Welcome back, " + account->name() + ".");
	QVector<unsigned long> characterUids = account->characters();
    auto characters = world::objects<Person>(characterUids);
	if(characters.count() == 1)
    {
        //login to the character immediately

		auto person = characters[0];
        if(person)
        {
			person->setDisconnected(false);
            aClient.setState(EClientStateNormal);
			aClient.linkToPerson(world::World::instance()->objectFactory()->getPtr<Person>(person->uid()));
			auto clientPtr = world::World::instance()->getClientPtr(aClient.id());
			if(!clientPtr)
				qDebug() << "Bad client ptr for person " << person->name() << " " << QString::number(person->uid());
			else
				person->attachClient(clientPtr);
            auto room = person->getRoom();
            if(room)
                room->printDescription(*person, aClient);
            return;
        }
        //otherwise show account menu
        state_ = ELoginStateAccountMenu;
    }

}
Ejemplo n.º 4
0
static inline uint8_t* tryAuth(union Headers_CryptoAuth* cauth,
                               uint8_t hashOutput[32],
                               struct Wrapper* wrapper,
                               void** userPtr)
{
    struct Auth* auth = getAuth(cauth->handshake.auth, wrapper->context);
    if (auth != NULL) {
        uint16_t deriv = Headers_getAuthChallengeDerivations(&cauth->handshake.auth);
        getPasswordHash(hashOutput, deriv, auth);
        if (deriv == 0) {
            *userPtr = auth->user;
        }
        return hashOutput;
    }
    wrapper->authenticatePackets |= Headers_isPacketAuthRequired(&cauth->handshake.auth);

    return NULL;
}
Ejemplo n.º 5
0
 bool SecretsManager::testMasterPassword(const QString &masterPasswordCandidate) const
 {
     QByteArray hashByteArray = getPasswordHash(masterPasswordCandidate);
     bool equals = hashByteArray == m_MasterPasswordHash;
     return equals;
 }