Heavy wip on login changes to get it to actually work like we want

This commit is contained in:
KimLS
2017-12-10 23:35:25 -08:00
parent 6b70faf141
commit 5bbeec626c
28 changed files with 338 additions and 138 deletions
+30 -29
View File
@@ -219,37 +219,38 @@ void Client::Handle_Login(const char* data, unsigned int size)
bool result = false;
if (outbuffer[0] == 0 && outbuffer[1] == 0) {
if (server.options.IsTokenLoginAllowed()) {
cred = (&outbuffer[2 + user.length()]);
result = server.db->GetLoginTokenDataFromToken(cred, connection->GetRemoteAddr(), db_account_id, user);
}
//if (server.options.IsTokenLoginAllowed()) {
// cred = (&outbuffer[2 + user.length()]);
// result = server.db->GetLoginTokenDataFromToken(cred, connection->GetRemoteAddr(), db_account_id, user);
//}
}
else {
if (server.options.IsPasswordLoginAllowed()) {
cred = (&outbuffer[1 + user.length()]);
if (server.db->GetLoginDataFromAccountName(user, db_account_password_hash, db_account_id) == false) {
/* If we have auto_create_accounts enabled in the login.ini, we will process the creation of an account on our own*/
if (
server.options.CanAutoCreateAccounts() &&
server.db->CreateLoginData(user, eqcrypt_hash(user, cred, mode), db_account_id) == true
) {
LogF(Logs::General, Logs::Error, "User {0} does not exist in the database, so we created it...", user);
result = true;
}
else {
LogF(Logs::General, Logs::Error, "Error logging in, user {0} does not exist in the database.", user);
result = false;
}
}
else {
if (eqcrypt_verify_hash(user, cred, db_account_password_hash, mode)) {
result = true;
}
else {
result = false;
}
}
}
//if (server.options.IsPasswordLoginAllowed()) {
// result = false;
// //cred = (&outbuffer[1 + user.length()]);
// //if (server.db->GetLoginDataFromAccountName(user, db_account_password_hash, db_account_id) == false) {
// // /* If we have auto_create_accounts enabled in the login.ini, we will process the creation of an account on our own*/
// // if (
// // server.options.CanAutoCreateAccounts() &&
// // server.db->CreateLoginData(user, eqcrypt_hash(user, cred, mode), db_account_id) == true
// // ) {
// // LogF(Logs::General, Logs::Error, "User {0} does not exist in the database, so we created it...", user);
// // result = true;
// // }
// // else {
// // LogF(Logs::General, Logs::Error, "Error logging in, user {0} does not exist in the database.", user);
// // result = false;
// // }
// //}
// //else {
// // if (eqcrypt_verify_hash(user, cred, db_account_password_hash, mode)) {
// // result = true;
// // }
// // else {
// // result = false;
// // }
// //}
//}
}
/* Login Accepted */