remove database(no need mongodb anymore)
This commit is contained in:
@@ -1,8 +1,5 @@
|
||||
namespace FreeSR.Dispatch
|
||||
{
|
||||
using FreeSR.Database;
|
||||
using FreeSR.Database.Account;
|
||||
using FreeSR.Database.Configuration;
|
||||
using FreeSR.Dispatch.Service;
|
||||
using FreeSR.Dispatch.Service.Manager;
|
||||
using FreeSR.Shared.Configuration;
|
||||
@@ -30,11 +27,6 @@
|
||||
ConfigurationManager<DispatchServerConfiguration>.Instance.Initialize("DispatchServer.json");
|
||||
var serverConfiguration = ConfigurationManager<DispatchServerConfiguration>.Instance.Model;
|
||||
|
||||
DatabaseManager.Instance.Initialize(serverConfiguration.Database);
|
||||
|
||||
var mongoDatabase = DatabaseManager.Instance.MongoDatabase;
|
||||
DatabaseManager.Instance.Add(new AccountDatabase(mongoDatabase, DatabaseManager.Instance.GetCollectionName(DatabaseType.Account)));
|
||||
|
||||
RegionManager.Initialize(serverConfiguration.Region);
|
||||
HttpDispatchService.Initialize(serverConfiguration.Network);
|
||||
|
||||
|
||||
@@ -3,16 +3,6 @@
|
||||
"Host": "0.0.0.0",
|
||||
"Port": 8888
|
||||
},
|
||||
"Database": {
|
||||
"ConnectionString": "mongodb://127.0.0.1:27017/",
|
||||
"Name": "FreeSR",
|
||||
"Entries": [
|
||||
{
|
||||
"CollectionName": "accounts",
|
||||
"Type": "Account"
|
||||
}
|
||||
]
|
||||
},
|
||||
"Region": {
|
||||
"Name": "FreeSR",
|
||||
"EnvType": "2",
|
||||
|
||||
@@ -1,13 +1,11 @@
|
||||
namespace FreeSR.Dispatch
|
||||
{
|
||||
using FreeSR.Database.Configuration;
|
||||
using FreeSR.Dispatch.Configuration;
|
||||
using FreeSR.Shared.Configuration;
|
||||
|
||||
internal class DispatchServerConfiguration
|
||||
{
|
||||
public NetworkConfiguration Network { get; set; }
|
||||
public DatabaseConfiguration Database { get; set; }
|
||||
public RegionConfiguration Region { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,7 +13,6 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\FreeSR.Database.Account\FreeSR.Database.Account.csproj" />
|
||||
<ProjectReference Include="..\FreeSR.Proto\FreeSR.Proto.csproj" />
|
||||
<ProjectReference Include="..\FreeSR.Shared\FreeSR.Shared.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
@@ -1,9 +1,6 @@
|
||||
namespace FreeSR.Dispatch.Handlers
|
||||
{
|
||||
using Ceen;
|
||||
using FreeSR.Database;
|
||||
using FreeSR.Database.Account;
|
||||
using FreeSR.Database.Account.Model;
|
||||
using FreeSR.Dispatch.Util;
|
||||
using FreeSR.Proto;
|
||||
using Newtonsoft.Json.Linq;
|
||||
@@ -19,30 +16,17 @@
|
||||
string data = await context.Request.Body.ReadAllAsStringAsync();
|
||||
JObject loginJson = JObject.Parse(data);
|
||||
|
||||
AccountDatabase accountDatabase = DatabaseManager.Instance.Get<AccountDatabase>();
|
||||
|
||||
string accountName = (string)loginJson["account"];
|
||||
string password = (string)loginJson["password"];
|
||||
|
||||
AccountModel account = await accountDatabase.GetByName(accountName);
|
||||
if (account == null)
|
||||
{
|
||||
await context.Response.WriteAllJsonAsync(DispatchResponseBuilder.Create()
|
||||
.Retcode((int)RetcodeStatus.RetFail)
|
||||
.Message("Account not found.")
|
||||
.Object("data", null)
|
||||
.Build());
|
||||
return true;
|
||||
}
|
||||
|
||||
// no password check, because client patch is closed-source for now.
|
||||
var accountData = DispatchHelper.ToLoginResponseData();
|
||||
|
||||
await context.Response.WriteAllJsonAsync(DispatchResponseBuilder.Create()
|
||||
.Retcode((int)RetcodeStatus.RetSucc)
|
||||
.Message("OK")
|
||||
.Object("data", new JObject
|
||||
{
|
||||
{"account", account.ToLoginResponseData()},
|
||||
{"account", accountData},
|
||||
{"device_grant_required", false},
|
||||
{"safe_moblie_required", false},
|
||||
{"realperson_required", false},
|
||||
|
||||
@@ -1,9 +1,6 @@
|
||||
namespace FreeSR.Dispatch.Handlers
|
||||
{
|
||||
using Ceen;
|
||||
using FreeSR.Database;
|
||||
using FreeSR.Database.Account;
|
||||
using FreeSR.Database.Account.Model;
|
||||
using FreeSR.Dispatch.Util;
|
||||
using FreeSR.Proto;
|
||||
using Newtonsoft.Json.Linq;
|
||||
@@ -13,41 +10,14 @@
|
||||
{
|
||||
public async Task<bool> HandleAsync(IHttpContext context)
|
||||
{
|
||||
var data = await context.Request.Body.ReadAllAsStringAsync();
|
||||
var json = JObject.Parse(data);
|
||||
|
||||
var uid = int.Parse((string)json["uid"]);
|
||||
var token = (string)json["token"];
|
||||
|
||||
AccountDatabase accountDatabase = DatabaseManager.Instance.Get<AccountDatabase>();
|
||||
AccountModel account = await accountDatabase.GetByUid(uid);
|
||||
if (account == null)
|
||||
{
|
||||
await context.Response.WriteAllJsonAsync(DispatchResponseBuilder.Create()
|
||||
.Retcode((int)RetcodeStatus.RetFail)
|
||||
.Message("Account not found.")
|
||||
.Object("data", null)
|
||||
.Build());
|
||||
|
||||
return true;
|
||||
}
|
||||
else if (account.Token != token)
|
||||
{
|
||||
await context.Response.WriteAllJsonAsync(DispatchResponseBuilder.Create()
|
||||
.Retcode((int)RetcodeStatus.RetFail)
|
||||
.Message("Invalid user token.")
|
||||
.Object("data", null)
|
||||
.Build());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
var accountData = DispatchHelper.ToLoginResponseData();
|
||||
await context.Response.WriteAllJsonAsync(DispatchResponseBuilder.Create()
|
||||
.Retcode((int)RetcodeStatus.RetSucc)
|
||||
.Message("OK")
|
||||
.Object("data", new JObject
|
||||
{
|
||||
{"account", account.ToLoginResponseData()},
|
||||
{"account", accountData},
|
||||
{"device_grant_required", false},
|
||||
{"safe_moblie_required", false},
|
||||
{"realperson_required", false},
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
using Ceen.Httpd;
|
||||
using Ceen.Httpd.Logging;
|
||||
using FreeSR.Dispatch.Handlers;
|
||||
using FreeSR.Dispatch.Handlers.Sdk;
|
||||
using FreeSR.Shared.Configuration;
|
||||
using System.Net;
|
||||
|
||||
@@ -30,8 +29,7 @@
|
||||
.AddRoute("/account/risky/api/check", new RiskyApiCheckHandler())
|
||||
.AddRoute("/hkrpg_global/mdk/agreement/api/getAgreementInfos", new GetAgreementInfosHandler())
|
||||
.AddRoute("/data_abtest_api/config/experiment/list", new GetExperimentListHandler())
|
||||
.AddRoute("/hkrpg_global/combo/granter/api/getConfig", new ComboGranterApiGetConfigHandler())
|
||||
.AddRoute("/sdk/createaccount", new CreateAccountHandler());
|
||||
.AddRoute("/hkrpg_global/combo/granter/api/getConfig", new ComboGranterApiGetConfigHandler());
|
||||
}
|
||||
|
||||
private static async Task BootHttpAsync(NetworkConfiguration config)
|
||||
|
||||
@@ -1,17 +1,16 @@
|
||||
namespace FreeSR.Dispatch.Util
|
||||
{
|
||||
using FreeSR.Database.Account.Model;
|
||||
using Newtonsoft.Json.Linq;
|
||||
|
||||
internal static class DispatchHelper
|
||||
{
|
||||
public static JObject ToLoginResponseData(this AccountModel model)
|
||||
public static JObject ToLoginResponseData()
|
||||
{
|
||||
return new JObject
|
||||
{
|
||||
{"uid", model.Uid},
|
||||
{"name", model.Name},
|
||||
{"email", "reversedrooms"},
|
||||
{"uid", 1337},
|
||||
{"name", "reversedrooms"},
|
||||
{"email", "reversedrooms@mihomo.com"},
|
||||
{"mobile", ""},
|
||||
{"is_email_verify", "0"},
|
||||
{"realname", ""},
|
||||
@@ -31,7 +30,7 @@
|
||||
{"steam_name", ""},
|
||||
{"unmasked_email", ""},
|
||||
{"unmasked_email_type", 0},
|
||||
{"token", model.Token}
|
||||
{"token", "FreesrToken"}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user