CrazyIter_Bin 4 месяцев назад
Родитель
Сommit
9923e3d4d6

+ 3 - 3
TEAMModelOS.Extension/IES.Exam/IES.ExamServer/Controllers/IndexController.cs

@@ -173,7 +173,7 @@ namespace IES.ExamServer.Controllers
                                 string randomCode = $"{json["randomCode"]}";
                                 System.Net.ServicePointManager.SecurityProtocol = System.Net.SecurityProtocolType.Tls12;
 
-                                var response = await _httpClientFactory.CreateClient().GetAsync($"{CenterUrl}/core/qrcode/check?code={randomCode}&school={school?.id}");
+                                var response = await _httpClientFactory.CreateClient().GetAsync($"{CenterUrl}/core/qrcode/check?randomcode={randomCode}&school={school?.id}&client=ExamServer");
                                 if (response.IsSuccessStatusCode)
                                 {
                                     string content = await response.Content.ReadAsStringAsync();
@@ -287,7 +287,7 @@ namespace IES.ExamServer.Controllers
                             randomcode = $"{random.Next(1000, 9999)}";
                             string? CenterUrl = _configuration.GetValue<string>("ExamServer:CenterUrl");
                             CenterUrl = CenterUrl.Equals("https://localhost:5001") ? "https://www.teammodel.cn" : CenterUrl;
-                            string content = $"{CenterUrl}/qrcodelogin?randomcode=login:{school?.id}:{randomcode}&m=%E6%89%AB%E7%A0%81%E7%99%BB%E5%BD%95&o=1";
+                            string content = $"{CenterUrl}/qrcodelogin?randomcode=login:ExamServer:{school?.id}:{randomcode}&m=%E6%89%AB%E7%A0%81%E7%99%BB%E5%BD%95&o=1";
                             var str = QRCodeHelper.GenerateQRCode(content, 300, 300, QRCodeHelper.logo);
                             qrcode = $"data:image/png;base64,{str}";
                             return Ok(new { code = 200, randomCode = randomcode, qrcode, type });
@@ -299,7 +299,7 @@ namespace IES.ExamServer.Controllers
                             randomcode = $"{random.Next(1000, 9999)}";
                             string? CenterUrl = _configuration.GetValue<string>("ExamServer:CenterUrl");
                             CenterUrl = CenterUrl.Equals("https://localhost:5001") ? "https://www.teammodel.cn" : CenterUrl;
-                            string content = $"{CenterUrl}/qrcodelogin?code=randomcode:{school?.id}:{randomcode}&m=%E6%89%AB%E7%A0%81%E7%99%BB%E5%BD%95&o=1";
+                            string content = $"{CenterUrl}/qrcodelogin?randomcode=login:ExamServer:{school?.id}:{randomcode}&m=%E6%89%AB%E7%A0%81%E7%99%BB%E5%BD%95&o=1";
                             Bitmap qrCodeImage = QRCodeHelper.GetBitmap(content, 200, 200);
                             using (MemoryStream stream = new MemoryStream())
                             {

+ 10 - 6
TEAMModelOS/Controllers/System/CoreController.cs

@@ -421,7 +421,7 @@ namespace TEAMModelOS.Controllers
         [ProducesDefaultResponseType]
         [HttpPost("qrcode/login")]
         //[Authorize(Roles = "HiTA")]
-        public async Task<IActionResult> SchoolJoin(HiTAJoinSchool join)
+        public async Task<IActionResult> SchoolJoin(QRCodeLoginCheck join)
         {
             try
             {
@@ -445,7 +445,7 @@ namespace TEAMModelOS.Controllers
                     await _azureRedis.GetRedisClient(8).StringSetAsync($"HiTA:Login:{join.randomcode.Replace("login:", "")}", id, expiry: new TimeSpan(0, 0, 30));
                     return Ok(new { msg = "关闭弹窗以获取登录信息" ,code=200});
                 }
-                else { return Ok(new { code = 400, msg = "参数错误" }); }
+                else { return Ok(new { code = 400, msg = $"参数错误{join.ToJsonString()}" }); }
                 
             }
             catch (Exception ex)
@@ -457,7 +457,7 @@ namespace TEAMModelOS.Controllers
 
         [ProducesDefaultResponseType]
         [HttpGet("qrcode/check")]
-        public async Task<IActionResult> QRCodeCheck([FromQuery] HiTAJoinSchool join)
+        public async Task<IActionResult> QRCodeCheck([FromQuery] QRCodeLoginCheck join)
         {
             int timezone = 8;
             if (HttpContext.Request.Headers.TryGetValue("Time-Zone", out var Time_Zone) && int.TryParse(Time_Zone, out int tz))
@@ -468,8 +468,7 @@ namespace TEAMModelOS.Controllers
             string school = join.school;
             if (!string.IsNullOrWhiteSpace(join.randomcode)&& !string.IsNullOrWhiteSpace(school))
             {
-                
-                var data = await _azureRedis.GetRedisClient(8).StringGetAsync($"HiTA:Login:{school}:{join.randomcode}");
+                var data = await _azureRedis.GetRedisClient(8).StringGetAsync($"HiTA:Login:{join.client}:{school}:{join.randomcode}");
                 if (data.HasValue)
                 {
                     tmdid = data.ToString();
@@ -1287,7 +1286,12 @@ namespace TEAMModelOS.Controllers
 
 
     public class QRCodeLoginCheck
-    { }
+    {
+        public string randomcode { get; set;}
+        public string school { get; set; }
+        public string client {  get; set; }
+        public string id_token {  get; set;}
+    }
     public record ApplySchool
     {
         /// <summary>