Пример #1
0
void ChatServer::processMessage(PasswordChangeRequest *msg)
{
    PasswordChangeResult *answer = new PasswordChangeResult;
    ChatClient client = m_clientList.getClient(msg->username);
    QString log;
    if(client.password() == msg->oldPassword)
    {
        client.setPassword(msg->newPassword);
        m_clientList.updateClient(client);
        answer->result = "Password changed!\nDon't forget to use new password in the next authorization.";
        log = "User " + msg->username + " changed his password";
        emit updateTable("clients");
    }
    else
    {
        answer->result = "Given old password is incorrect!";
        log = "User " + msg->username + " tried to change his password. Unfortunately, unsuccessfull.";
    }
    emit serverLog(esNotify, log);
    sendMessageToClient(msg->username, answer);
}