更改了授权Api

This commit is contained in:
CortexCore 2023-09-23 23:01:39 +08:00
parent c65fe87a6c
commit 6fab30a15c
5 changed files with 16 additions and 15 deletions

View File

@ -36,7 +36,7 @@ text = "等待激活许可证中"
layout_mode = 2
text = "点击开始加载许可证"
script = ExtResource("1_pw177")
url = "http://server.bitfall.icu:5252/oauth"
url = "https://oauth.bitfall.icu/oauth/5348"
[node name="授权服务" type="Node" parent="."]
script = ExtResource("2_j02yv")

View File

@ -77,17 +77,17 @@ public partial class LicenseService : EntityComponent,IAuthService
private HttpContent OnRequest(HttpListenerRequest arg)
{
var token = arg.RawUrl!.Split('/').Last();
//if (arg.HttpMethod is not "POST" or not "OPTIONS") return new StringContent(ContextModel.Error("Method Not Allowed"));
var sr = new StreamReader(arg.InputStream);
var token = sr.ReadToEnd();
AuthorizeAsync(token).Forget();
return new StringContent("success");
return new StringContent(ContextModel.Get(true));
}
public async UniTask AuthorizeAsync(string token)
{
var rawToken = token;
OnAuthorize?.Invoke(token);
token = JsonConvert.SerializeObject(token);
var response = await _httpClient.PostAsync(_requestAuthorizeUrl,new StringContent( token,Encoding.UTF8, "application/json"), _cancellationToken);
var response = await _httpClient.PostAsync(_requestAuthorizeUrl,new StringContent( JsonConvert.SerializeObject(token),Encoding.UTF8, "application/json"), _cancellationToken);
var message = await response.Content.ReadAsStringAsync(_cancellationToken);
if (response.IsSuccessStatusCode)
{
@ -95,7 +95,7 @@ public partial class LicenseService : EntityComponent,IAuthService
BIT4Log.Log<IAuthService>($"授权成功:{message}");
var licenseBin = new LicenseBin
{
Token = rawToken,
Token = token,
ExpirationDate = DateTime.Now.AddDays(7)
};
PathHelper.EnsureDirectoryCreated(path);
@ -105,7 +105,7 @@ public partial class LicenseService : EntityComponent,IAuthService
else
{
OnAuthorizeFailure?.Invoke(message);
BIT4Log.Log<IAuthService>($"当前Token:{rawToken}");
BIT4Log.Log<IAuthService>($"当前Token:{token}");
BIT4Log.Log<IAuthService>($"授权失败:{message}");
}
}

File diff suppressed because one or more lines are too long

View File

@ -18,6 +18,7 @@ public partial class IDIS_License : EntityComponent
}
private async void OnAuthorized(string obj)
{
_authService.OnAuthorized -= OnAuthorized;
await BITApp.SwitchToMainThread();
GetParent().AddChild(initialScene.Instantiate());
licenseNode.QueueFree();

View File

@ -17,7 +17,7 @@ config/features=PackedStringArray("4.1", "C#", "Forward Plus")
run/low_processor_mode=true
boot_splash/bg_color=Color(0.00392157, 0, 0.00392157, 1)
config/icon="res://icon.svg"
config/version="1.03"
config/version="1.0.0.4"
[autoload]