BACKEND: use logid

master
Martin Gerhardy 2020-11-30 23:57:34 +01:00
parent 22582be1ff
commit 390ad0bd1b
1 changed files with 6 additions and 6 deletions

View File

@ -25,7 +25,7 @@ static core::String generateSignupToken(unsigned int seed) {
}
void SignupHandler::sendTokenMail(const core::String& email, const core::String& token) {
Log::info("Send token mail to %s", email.c_str());
Log::info(logid, "Send token mail to %s", email.c_str());
// TODO: send mail https://tools.ietf.org/html/rfc5321
// send mail to a mail relay that listens on localhost without tls for local connections. The TLS is handled in the relay
// this would allow us to send a mail with a few lines of code without all the hassle....
@ -42,14 +42,14 @@ void SignupHandler::executeWithRaw(ENetPeer* peer, const void* raw, const uint8_
const core::String password(message->password()->c_str());
if (password.empty()) {
Log::debug("Abort signup. No password was given.");
Log::debug(logid, "Abort signup. No password was given.");
return;
}
db::DBConditionUserModelEmail userEmailCond(email);
const int count = _dbHandler->count(db::UserModel(), userEmailCond);
if (count != 0) {
Log::info("Abort signup. Account for %s already exists", email.c_str());
Log::debug(logid, "Abort signup. Account for %s already exists.", email.c_str());
// TODO: allow to claim via token
return;
}
@ -60,17 +60,17 @@ void SignupHandler::executeWithRaw(ENetPeer* peer, const void* raw, const uint8_
userModel.setName(email);
userModel.setPassword(core::pwhash(password, "TODO"));
if (!_dbHandler->insert(userModel)) {
Log::error("Failed to register user for %s", email.c_str());
Log::error(logid, "Abort signup. Failed to register user for %s", email.c_str());
return;
}
const core::String& token = generateSignupToken(((uint32_t)(intptr_t)this) + peer->connectID);
Log::info("User registered with id %i: %s", (int)userModel.id(), email.c_str());
Log::info(logid, "User registered with id %i: %s", (int)userModel.id(), email.c_str());
db::SignupModel model;
model.setUserid(userModel.id());
model.setToken(token);
if (!_dbHandler->insert(model)) {
Log::info(logid, "Could not create signup request for %s.", email.c_str());
Log::error(logid, "Could not create signup request for %s.", email.c_str());
return;
}