|
@@ -149,15 +149,21 @@ namespace IES.ExamServer.Controllers
|
|
|
List<School>? schools = null;
|
|
|
JsonNode? jsonNode = null;
|
|
|
long time = DateTimeOffset.Now.ToUnixTimeMilliseconds();
|
|
|
+ _memoryCache.TryGetValue(Constant._KeyServerDevice, out ServerDevice? server);
|
|
|
+ School? school = null;
|
|
|
+ if (server!=null)
|
|
|
+ {
|
|
|
+ school = server.school;
|
|
|
+ }
|
|
|
switch (true)
|
|
|
{
|
|
|
//跳过忽略,但是仍然要以访客身份登录
|
|
|
case bool when $"{type}".Equals(ExamConstant.ScopeVisitor):
|
|
|
{
|
|
|
string id = $"{DateTimeOffset.Now.ToUnixTimeSeconds()}";
|
|
|
- string name = $"访客教师-{Random.Shared.Next(100, 999)}";
|
|
|
- x_auth_token = JwtAuthExtension.CreateAuthToken("www.teammodel.cn",id ,name,null
|
|
|
- ,ExamConstant.JwtSecretKey,ExamConstant.ScopeVisitor,8,null,new string[] { "visitor" }, expire: 1);
|
|
|
+ string name = $"{school?.name}教师-{Random.Shared.Next(100, 999)}";
|
|
|
+ x_auth_token = JwtAuthExtension.CreateAuthToken("www.teammodel.cn",id ,name,picture: school?.picture
|
|
|
+ , ExamConstant.JwtSecretKey,ExamConstant.ScopeVisitor,8,schoolID:school?.id,new string[] { "visitor" }, expire: 1);
|
|
|
// _memoryCache.Set($"Teacher:{id}", new Teacher { id = id, name = $"{name}", implicit_token = token, picture = null, schools = schools, x_auth_token = x_auth_token });
|
|
|
_liteDBFactory.GetLiteDatabase().GetCollection<Teacher>().Upsert(new Teacher { id = id, name = $"{name}", implicit_token = token, picture = null, schools = schools, x_auth_token = x_auth_token,loginTime=time });
|
|
|
return Ok(new { code = 200,x_auth_token = x_auth_token });
|
|
@@ -167,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}/hita/check-login?code={randomCode}");
|
|
|
+ var response = await _httpClientFactory.CreateClient().GetAsync($"{CenterUrl}/hita/check-login?code={randomCode}&school={school?.id}");
|
|
|
if (response.IsSuccessStatusCode)
|
|
|
{
|
|
|
string content = await response.Content.ReadAsStringAsync();
|
|
@@ -192,7 +198,7 @@ namespace IES.ExamServer.Controllers
|
|
|
{
|
|
|
string pin_code = $"{json["pin_code"]}";
|
|
|
string account = $"{json["account"]}";
|
|
|
- var response = await _httpClientFactory.CreateClient().PostAsJsonAsync($"{CenterUrl}/core/sendsms/check", new { pin_code, account });
|
|
|
+ var response = await _httpClientFactory.CreateClient().PostAsJsonAsync($"{CenterUrl}/core/sendsms/check", new { pin_code, account,school=school?.id });
|
|
|
if (response.IsSuccessStatusCode)
|
|
|
{
|
|
|
string content = await response.Content.ReadAsStringAsync();
|
|
@@ -272,6 +278,7 @@ namespace IES.ExamServer.Controllers
|
|
|
Random random = new Random();
|
|
|
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}/joinSchool?schoolCode=login:{randomCode}&m=%E7%99%BB%E5%BD%95&o=1";
|
|
|
var str= QRCodeHelper.GenerateQRCode(content, 300, 300,QRCodeHelper.logo);
|
|
|
qrcode = $"data:image/png;base64,{str}";
|
|
@@ -283,6 +290,7 @@ namespace IES.ExamServer.Controllers
|
|
|
Random random = new Random();
|
|
|
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}/joinSchool?schoolCode=login:{randomCode}&m=%E7%99%BB%E5%BD%95&o=1";
|
|
|
Bitmap qrCodeImage = QRCodeHelper.GetBitmap(content, 200, 200);
|
|
|
using (MemoryStream stream = new MemoryStream())
|