rust/hedgewars-server/src/server/database.rs
changeset 15110 6a8c294f49c9
parent 15109 acd50a72af59
child 15121 1a43b570cbe4
equal deleted inserted replaced
15109:acd50a72af59 15110:6a8c294f49c9
    67                     from_row_opt::<(String, i32, i32)>(row)?;
    67                     from_row_opt::<(String, i32, i32)>(row)?;
    68                 let client_hash = get_hash(protocol, &password, &client_salt, &server_salt);
    68                 let client_hash = get_hash(protocol, &password, &client_salt, &server_salt);
    69                 let server_hash = get_hash(protocol, &password, &server_salt, &client_salt);
    69                 let server_hash = get_hash(protocol, &password, &server_salt, &client_salt);
    70                 password.replace_range(.., "🦔🦔🦔🦔🦔🦔🦔🦔");
    70                 password.replace_range(.., "🦔🦔🦔🦔🦔🦔🦔🦔");
    71 
    71 
    72                 if password_hash == client_hash {
    72                 if password_hash == format!("{:x}", client_hash) {
    73                     Ok(Some(AccountInfo {
    73                     Ok(Some(AccountInfo {
    74                         is_registered: true,
    74                         is_registered: true,
    75                         is_admin: is_admin == 1,
    75                         is_admin: is_admin == 1,
    76                         is_contributor: is_contributor == 1,
    76                         is_contributor: is_contributor == 1,
    77                         server_hash,
    77                         server_hash,
    78                     }))
    78                     }))
    79                 } else {
    79                 } else {
    80                     Ok(None)
    80                     Ok(None)
    81                 }
    81                 }
    82             } else {
    82             } else {
    83                 Ok(Some(AccountInfo {
    83                 Ok(None)
    84                     is_registered: false,
       
    85                     is_admin: false,
       
    86                     is_contributor: false,
       
    87                     server_hash: Sha1Digest::new([0; 20]),
       
    88                 }))
       
    89             }
    84             }
    90         } else {
    85         } else {
    91             Err(DriverError::SetupError.into())
    86             Err(DriverError::SetupError.into())
    92         }
    87         }
    93     }
    88     }