Skip to content

Instantly share code, notes, and snippets.

@miles200
Created February 17, 2019 17:59
Show Gist options
  • Save miles200/0297f05006b4a703fab356fa3725c704 to your computer and use it in GitHub Desktop.
Save miles200/0297f05006b4a703fab356fa3725c704 to your computer and use it in GitHub Desktop.
if(!msg->m_data.valid()) // no account exists, check if auto create account true
{
QSettings settings(Settings::getSettingsPath(), QSettings::IniFormat);
settings.beginGroup("AutoUser");
bool auto_user_create = settings.value("auto_user_create", "").toBool();
int access_level = settings.value("user_access_level", "").toInt();
settings.endGroup();
if (auto_user_create == true) // create account
{
qDebug()<<msg->m_data.m_login;
if (m_db_error.isEmpty())
{
EventProcessor *tgt = HandlerLocator::getAuthDB_Handler();
tgt->putq(new CreateAccountMessage({"test", m_password, access_level}, 0, this));
tgt->putq(new RetrieveAccountRequest({"test", m_password, 0}, sess_token, this));
return; // Terminate and restart once RetrieveAccountResponse does its thing
}
else
{
qDebug()<<"Error creating auto account: " << m_db_error; // could be name already taken? We'll show the usual error here
lnk->putq(s_auth_error_wrong_login_pass.shallow_copy());
m_db_error.clear();
return;
}
}
else // auto create account false, return proper response
{
lnk->putq(s_auth_error_wrong_login_pass.shallow_copy());
return;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment