Fixing error handling for invalid username+password hashes
This commit is contained in:
parent
0d8642e7ce
commit
4f47bfe2b6
3 changed files with 14 additions and 1 deletions
|
@ -252,10 +252,16 @@ static server_type open_connection(game_display& disp, const std::string& origin
|
|||
sp["username"] = login ;
|
||||
sp["password_reminder"] = password_reminder;
|
||||
|
||||
//If password is not empty start hashing
|
||||
// If password is not empty start hashing
|
||||
|
||||
std::string result;
|
||||
if(!(password.empty())) {
|
||||
|
||||
// Check if we have everything we need
|
||||
if((*error)["salt"].empty() || (*error)["hash_seed"].empty()) {
|
||||
return ABORT_SERVER;
|
||||
}
|
||||
|
||||
std::string itoa64("./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz");
|
||||
|
||||
std::string salt = (*error)["salt"];
|
||||
|
|
|
@ -60,6 +60,8 @@ class fuh : public user_handler {
|
|||
* from the original hash to recreate the same hash
|
||||
* index = 0 returns the hash seed
|
||||
* index = 1 return the salt
|
||||
*
|
||||
* Return an empty string if an error occurs
|
||||
*/
|
||||
std::string create_pepper(const std::string& name, int index);
|
||||
|
||||
|
|
|
@ -442,6 +442,11 @@ void server::send_password_request(network::connection sock, const char* msg, co
|
|||
std::string salt1 = user_handler_->create_salt();
|
||||
std::string salt2 = user_handler_->create_pepper(user, 0);
|
||||
std::string salt3 = user_handler_->create_pepper(user, 1);
|
||||
if(salt2.empty() || salt3.empty()) {
|
||||
send_error(sock, "Even though your nick is registered on this server you"
|
||||
"cannot log in due to an error in the hashing algorithm.");
|
||||
return;
|
||||
}
|
||||
|
||||
seeds_.insert(std::pair<network::connection,std::string>(sock, salt1));
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue