diff --git a/Campofinale/ConfigFile.cs b/Campofinale/ConfigFile.cs index ff11295..99887b7 100644 --- a/Campofinale/ConfigFile.cs +++ b/Campofinale/ConfigFile.cs @@ -25,22 +25,10 @@ /// Not yet implemented /// public bool useEncryption = false; - //public CharactersOptions defaultCharacters = new(); public ServerOptions() { } - /*public class CharactersOptions - { - public int defaultLevel = 1; - public bool giveAllCharacters = true; - public List characters = new List(); //used if giveAllCharacters is false - - public CharactersOptions() { } - }*/ - /* public struct WelcomeMail - { - }*/ } public class LogSettings { @@ -59,6 +47,8 @@ public int bindPort = 30000; public string accessAddress = "127.0.0.1"; public int accessPort = 30000; + public bool useExternalAuthSdk = false; + public string externalAuthSdkUrl = ""; public GameserverSettings() { } diff --git a/Campofinale/Database/Database.cs b/Campofinale/Database/Database.cs index 5b591a6..84af0ee 100644 --- a/Campofinale/Database/Database.cs +++ b/Campofinale/Database/Database.cs @@ -362,6 +362,11 @@ namespace Campofinale.Database } public Account GetAccountByTokenGrant(string token) { + if (Server.config.gameServer.useExternalAuthSdk) + { + //TODO get account info from external auth sdk + return null; + } try { return _database.GetCollection("accounts").Find(p => p.grantToken == token).ToList().FirstOrDefault(); diff --git a/Campofinale/Http/SDK.cs b/Campofinale/Http/SDK.cs index f6261a4..c097c30 100644 --- a/Campofinale/Http/SDK.cs +++ b/Campofinale/Http/SDK.cs @@ -14,10 +14,7 @@ namespace Campofinale.Http string requestBody = ctx.Request.DataAsString; Console.WriteLine(requestBody); string resp = "{}"; - - ctx.Response.StatusCode = 200; - //ctx.Response.ContentLength = resp.Length; ctx.Response.ContentType = "application/json"; await ctx.Response.SendAsync(resp); @@ -42,7 +39,6 @@ namespace Campofinale.Http } ctx.Response.StatusCode = 200; - //ctx.Response.ContentLength = resp.Length; ctx.Response.ContentType = "application/json"; await ctx.Response.SendAsync(resp); @@ -66,7 +62,6 @@ namespace Campofinale.Http } ctx.Response.StatusCode = 200; - //ctx.Response.ContentLength = resp.Length; ctx.Response.ContentType = "application/json"; await ctx.Response.SendAsync(resp); @@ -87,7 +82,7 @@ namespace Campofinale.Http if (account != null) { /* - * {"data":{"hgId":"1326618825955","phone":"153****5243","email":null,"identityNum":"5002**********1619","identityName":"金*","isMinor":false,"isLatestUserAgreement":true},"msg":"OK","status":0,"type":"A"} + * {"data":{"hgId":"**********","phone":"153****5243","email":null,"identityNum":"5002**********1619","identityName":"金*","isMinor":false,"isLatestUserAgreement":true},"msg":"OK","status":0,"type":"A"} */ resp = "{\"data\":{\"phone\":\"153****5243\", \"identityNum\": \"5002**********1619\",\"identityName\":\"金*\",\"isMinor\":false,\"hgId\":\"" + account.id + "\",\"email\":\"" + account.username +Server.config.dispatchServer.emailFormat +"\",\"realEmail\":\"" + account.username + Server.config.dispatchServer.emailFormat + "\",\"isLatestUserAgreement\":true,\"nickName\":\"" + account.username + "\"},\"msg\":\"OK\",\"status\":0,\"type\":\"A\"}"; } @@ -100,7 +95,6 @@ namespace Campofinale.Http ctx.Response.StatusCode = 200; - //ctx.Response.ContentLength = resp.Length; ctx.Response.ContentType = "application/json"; await ctx.Response.SendAsync(resp); @@ -182,14 +176,7 @@ namespace Campofinale.Http } } - /*{ - "appCode": "2fe67ec91610377d", - "code": "121212", - "email": "aaaa@a.cc", - "from": 0, - "password": "aaaaaaaaaaaaaa1" - }*/ - public struct RegisterData + public struct RegisterFormData { public string appCode; public string code; @@ -203,7 +190,7 @@ namespace Campofinale.Http { string requestBody = ctx.Request.DataAsString; Console.WriteLine(requestBody); - RegisterData data = Newtonsoft.Json.JsonConvert.DeserializeObject(requestBody); + RegisterFormData data = Newtonsoft.Json.JsonConvert.DeserializeObject(requestBody); string username = data.email.Split("@")[0]; (string,int) msg=DatabaseManager.db.CreateAccount(username); string resp = ""; @@ -267,9 +254,6 @@ namespace Campofinale.Http resp = File.ReadAllText("Data/GachaHistory/index_noplayerfound.html"); } - - - ctx.Response.StatusCode = 200; await ctx.Response.SendAsync(resp); diff --git a/Campofinale/Packets/Cs/HandleCsLogin.cs b/Campofinale/Packets/Cs/HandleCsLogin.cs index 7e08074..c79efbd 100644 --- a/Campofinale/Packets/Cs/HandleCsLogin.cs +++ b/Campofinale/Packets/Cs/HandleCsLogin.cs @@ -72,6 +72,16 @@ namespace Campofinale.Packets.Cs return; } Account account = DatabaseManager.db.GetAccountByTokenGrant(req.Token); + if (account==null) + { + session.Send(ScMsgId.ScNtfErrorCode, new ScNtfErrorCode() + { + Details = "Auth Error", + ErrorCode = (int)CODE.ErrLoginProcessLogin, + }); + session.Disconnect(); + return; + } ScLogin rsp = new() { IsEnc = false,