forked from reversedrooms/FireflySR
Disable password check
This commit is contained in:
parent
87bb318d63
commit
04b9d60ab4
4 changed files with 14 additions and 5 deletions
|
@ -1,3 +1,4 @@
|
||||||
|
// This file is @generated by prost-build.
|
||||||
#[allow(clippy::derive_partial_eq_without_eq)]
|
#[allow(clippy::derive_partial_eq_without_eq)]
|
||||||
#[derive(Clone, PartialEq, ::prost::Message)]
|
#[derive(Clone, PartialEq, ::prost::Message)]
|
||||||
pub struct PlayerBasicCompBin {
|
pub struct PlayerBasicCompBin {
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
{
|
{
|
||||||
"http_port": 21000,
|
"http_port": 21000,
|
||||||
"dispatch_endpoint": "http://127.0.0.1:21041",
|
"dispatch_endpoint": "http://127.0.0.1:21041",
|
||||||
|
"disable_password_check": false,
|
||||||
"database": {
|
"database": {
|
||||||
"connection_string": "mongodb://127.0.0.1:27017",
|
"connection_string": "mongodb://127.0.0.1:27017",
|
||||||
"name": "FireflySR",
|
"name": "FireflySR",
|
||||||
|
|
|
@ -14,6 +14,7 @@ pub struct SDKServerConfiguration {
|
||||||
pub http_port: u16,
|
pub http_port: u16,
|
||||||
pub dispatch_endpoint: String,
|
pub dispatch_endpoint: String,
|
||||||
pub database: DatabaseConfig,
|
pub database: DatabaseConfig,
|
||||||
|
pub disable_password_check: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
lazy_static! {
|
lazy_static! {
|
||||||
|
|
|
@ -3,7 +3,7 @@ use common::document::AccountDocument;
|
||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
use serde_json::json;
|
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 LOGIN: &str = "/:product_name/mdk/shield/api/login";
|
||||||
const VERIFY: &str = "/:product_name/mdk/shield/api/verify";
|
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 {
|
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)");
|
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 {
|
let account = match database::get_account_by_name(&context.db_client, &request.account).await {
|
||||||
Ok(Some(account)) => account,
|
Ok(Some(account)) => account,
|
||||||
|
@ -48,7 +54,7 @@ async fn login(
|
||||||
Err(_) => return fail_json(-1, "Internal server error"),
|
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");
|
return fail_json(-101, "Account or password error");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue