|
@@ -202,11 +202,12 @@ namespace TEAMModelOS.Controllers.Third
|
|
|
var bind = teacher.binds.Find(x => x.userid.Equals($"{scsso.tid}"));
|
|
|
if (bind == null)
|
|
|
{
|
|
|
- teacher.binds = new List<Teacher.ThirdBind> { new Teacher.ThirdBind { data = new List<string> { scsso.data }, userid = $"{scsso.tid}", /*source = $"{scsso.Webid}",*/ type = type } };
|
|
|
+ teacher.binds = new List<Teacher.ThirdBind> { new Teacher.ThirdBind { data = new List<string> { scsso.data }, userid = $"{scsso.tid}",username=scsso.username, type = type } };
|
|
|
await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "Teacher").ReplaceItemAsync<Teacher>(teacher, teacher.id, new PartitionKey(teacher.code));
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
+ bind.username=scsso.username;
|
|
|
var bindData = scsso.data.ToObject<ScBindData>();
|
|
|
bool isnew = true;
|
|
|
for (int index = 0; index < bind.data.Count; index++)
|
|
@@ -222,6 +223,10 @@ namespace TEAMModelOS.Controllers.Third
|
|
|
{
|
|
|
bind.data.Add(bindData.ToJsonString());
|
|
|
}
|
|
|
+ if (bindData != null) {
|
|
|
+ bindData.userid = scsso.tid;
|
|
|
+ bindData.username=scsso.username;
|
|
|
+ }
|
|
|
await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "Teacher").ReplaceItemAsync<Teacher>(teacher, teacher.id, new PartitionKey(teacher.code));
|
|
|
await _azureStorage.UploadFileByContainer("teammodelos", bindData.ToJsonString(), $"yxpt/{scsso.path}/scbind", $"{teacher.id}.json");
|
|
|
}
|
|
@@ -258,7 +263,18 @@ namespace TEAMModelOS.Controllers.Third
|
|
|
var container = _azureStorage.GetBlobContainerClient(id);
|
|
|
await container.CreateIfNotExistsAsync(PublicAccessType.None); //嘗試創建Teacher私有容器,如存在則不做任何事,保障容器一定存在
|
|
|
teacher = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "Teacher").CreateItemAsync<Teacher>(teacher, new PartitionKey("Base"));
|
|
|
- await _azureStorage.UploadFileByContainer("teammodelos", scsso.data.ToJsonString(), $"yxpt/{scsso.path}/scbind", $"{teacher.id}.json");
|
|
|
+
|
|
|
+ ScBindData bindData = scsso.data.ToObject<ScBindData>();
|
|
|
+ if (bindData != null)
|
|
|
+ {
|
|
|
+ bindData.userid = scsso.tid;
|
|
|
+ bindData.username = scsso.username;
|
|
|
+ await _azureStorage.UploadFileByContainer("teammodelos", bindData.ToJsonString(), $"yxpt/{scsso.path}/scbind", $"{teacher.id}.json");
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ await _azureStorage.UploadFileByContainer("teammodelos", scsso.data.ToJsonString(), $"yxpt/{scsso.path}/scbind", $"{teacher.id}.json");
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
catch (Exception ex) {
|
|
|
await _dingDing.SendBotMsg($"OS,{_option.Location}\n绑定失败:\n{sso.ToJsonString()},{ex.Message}\n{ex.StackTrace}", GroupNames.成都开发測試群組);
|
|
@@ -338,7 +354,7 @@ namespace TEAMModelOS.Controllers.Third
|
|
|
}
|
|
|
string accessConfig = setting.accessConfig;
|
|
|
Dictionary<string, object> dict = new Dictionary<string, object> { { "accessConfig", accessConfig }, { "pxid", scsso.Pxid }, { "tid", scsso.tid } };
|
|
|
- string SchoolName="",SchoolID = "", ProjectID = "", ProjectItemID ="" ;
|
|
|
+ string SchoolName = "", SchoolID = "", ProjectID = "", ProjectItemID = "", TeacherName = "" ;
|
|
|
|
|
|
(int status, string json) = await _httpTrigger.RequestHttpTrigger(dict, _option.Location, "GetSingleTeacherByProject");
|
|
|
if (status == 200)
|
|
@@ -351,6 +367,7 @@ namespace TEAMModelOS.Controllers.Third
|
|
|
SchoolID = $"{scTeacher.SchoolID}";
|
|
|
ProjectID =$"{ scTeacher.ProjectID}";
|
|
|
ProjectItemID =$"{ scTeacher.ProjectItemID}";
|
|
|
+ TeacherName = $"{ scTeacher.TeacherName}";
|
|
|
}
|
|
|
}
|
|
|
ScBindData bindData = new ScBindData
|
|
@@ -359,10 +376,14 @@ namespace TEAMModelOS.Controllers.Third
|
|
|
sid = SchoolID,
|
|
|
pd = ProjectID,
|
|
|
pid = ProjectItemID,
|
|
|
- pxid = scsso.Pxid
|
|
|
+ pxid = scsso.Pxid,
|
|
|
+ userid=scsso.tid,
|
|
|
+ username=TeacherName
|
|
|
+
|
|
|
};
|
|
|
var data = bindData.ToJsonString();
|
|
|
ScSSOData sso = new ScSSOData {
|
|
|
+ username = TeacherName,
|
|
|
path = path,
|
|
|
Pxid = scsso.Pxid,
|
|
|
Encrypt = scsso.Encrypt,
|
|
@@ -425,25 +446,8 @@ namespace TEAMModelOS.Controllers.Third
|
|
|
{
|
|
|
bind.data.Add(bindData.ToJsonString());
|
|
|
}
|
|
|
+ bind.username = TeacherName;
|
|
|
await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "Teacher").ReplaceItemAsync<Teacher>(teacher, teacher.id, new PartitionKey(teacher.code));
|
|
|
- //var scbind= bind.data.FindAll(x=>x.Contains("scsyxpt"));
|
|
|
- //if (scbind != null) {
|
|
|
- // foreach (var bd in scbind) {
|
|
|
-
|
|
|
- // }
|
|
|
- //}
|
|
|
- //if (bind.pxid != null)
|
|
|
- //{
|
|
|
- // if (bind.pxid.Add(sso.Pxid))
|
|
|
- // {
|
|
|
- // await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "Teacher").ReplaceItemAsync<Teacher>(teacher, teacher.id, new PartitionKey(teacher.code));
|
|
|
- // }
|
|
|
- //}
|
|
|
- //else
|
|
|
- //{
|
|
|
- // bind.pxid = new HashSet<string> { sso.Pxid };
|
|
|
- // await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "Teacher").ReplaceItemAsync<Teacher>(teacher, teacher.id, new PartitionKey(teacher.code));
|
|
|
- //}
|
|
|
}
|
|
|
await _azureStorage.UploadFileByContainer("teammodelos", bindData.ToJsonString(), $"yxpt/{sso.path}/scbind", $"{teacher.id}.json");
|
|
|
rurl.Append($"?status=200&id_token={implicit_token.id_token}&access_token={implicit_token.access_token}&expires_in={HttpUtility.UrlEncode(implicit_token.expires_in)}&token_type={HttpUtility.UrlEncode(implicit_token.token_type)}").ToString();
|
|
@@ -1041,6 +1045,7 @@ namespace TEAMModelOS.Controllers.Third
|
|
|
public string time { get; set; }
|
|
|
public string Encrypt { get; set; }
|
|
|
public string data { get; set; }
|
|
|
+ public string username { get; set; }
|
|
|
}
|
|
|
public record SSO
|
|
|
{
|