General 2.2.53 support & fix typo #1

Merged
xeon merged 5 commits from YYHEggEgg/FireflySR:master into master 2024-05-22 17:00:19 +00:00
4 changed files with 14 additions and 5 deletions
Showing only changes of commit 04b9d60ab4 - Show all commits

View file

@ -1,3 +1,4 @@
// This file is @generated by prost-build.
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct PlayerBasicCompBin {

View file

@ -1,6 +1,7 @@
{
"http_port": 21000,
"dispatch_endpoint": "http://127.0.0.1:21041",
"disable_password_check": false,
"database": {
"connection_string": "mongodb://127.0.0.1:27017",
"name": "FireflySR",

View file

@ -14,6 +14,7 @@ pub struct SDKServerConfiguration {
pub http_port: u16,
pub dispatch_endpoint: String,
pub database: DatabaseConfig,
pub disable_password_check: bool,
}
lazy_static! {

View file

@ -3,7 +3,7 @@ use common::document::AccountDocument;
use serde::Deserialize;
use serde_json::json;
use crate::{database, util, SdkContext};
use crate::{config::CONFIGURATION, database, util, SdkContext};
const LOGIN: &str = "/:product_name/mdk/shield/api/login";
const VERIFY: &str = "/:product_name/mdk/shield/api/verify";
@ -38,9 +38,15 @@ async fn login(
);
}
let Ok(password) = util::decrypt_string(&request.password) else {
return fail_json(-10, "Your patch is outdated.\r\nGet new one at https://discord.gg/reversedrooms\r\n(Password decryption failed)");
};
let mut password_opt: Option<String> = None;
if !CONFIGURATION.disable_password_check
{
if let Ok(password) = util::decrypt_string(&request.password) {
password_opt = Some(password);
} else {
return fail_json(-10, "Your patch is outdated.\r\nGet new one at https://discord.gg/reversedrooms\r\n(Password decryption failed)");
};
}
let account = match database::get_account_by_name(&context.db_client, &request.account).await {
Ok(Some(account)) => account,
@ -48,7 +54,7 @@ async fn login(
Err(_) => return fail_json(-1, "Internal server error"),
};
if util::verify_password(&password, &account.account_password).is_err() {
if CONFIGURATION.disable_password_check || util::verify_password(&password_opt.unwrap(), &account.account_password).is_err() {
return fail_json(-101, "Account or password error");
}