CrazyIter_Bin 3 years ago
parent
commit
25aa3b28f1
1 changed files with 26 additions and 45 deletions
  1. 26 45
      TEAMModeBI/Controllers/LoginController.cs

+ 26 - 45
TEAMModeBI/Controllers/LoginController.cs

@@ -229,27 +229,22 @@ namespace TEAMModeBI.Controllers
                 }
                 else
                 {
-                    var url = _configuration.GetValue<string>("HaBookAuth:CoreAPI");
                     var clientID = _configuration.GetValue<string>("HaBookAuth:CoreService:clientID");
-                    var clientSecret = _configuration.GetValue<string>("HaBookAuth:CoreService:clientSecret");
-                    var logintion = _option.Location;
-                    //隐式登录
-                    (int code, string content) = await _aoreAPIHttpService.Implicit(clientID, clientSecret, logintion, $"{url}/oauth2/implicit",
+                    var location = _option.Location;
+                    TmdidImplicit implicit_token = await _aoreAPIHttpService.Implicit(
                         new Dictionary<string, string>()
                         {
-                            { "grant_type", "implicit" },
-                            { "client_id",clientID},
-                            { "account",teacher.id},
-                            { "nonce",Guid.NewGuid().ToString()}
-                        });
+                        { "grant_type", "implicit" },
+                        { "client_id",clientID },
+                        { "account",teacher.id },
+                        { "nonce",Guid.NewGuid().ToString()}
+                        }, location, _configuration);
 
                     Dictionary<string, object> dic = new Dictionary<string, object> { { "PartitionKey", "authority-bi" } };//设置只访问BI的权限
                     List<Authority> authorityBIList = await _azureStorage.FindListByDict<Authority>(dic);  //获取权限列表
 
-                    TmdidImplicit implicit_token = new TmdidImplicit();
-                    if (!string.IsNullOrEmpty(content) && code == 200)
+                    if (implicit_token!=null)
                     {
-                        implicit_token = content.ToObject<TmdidImplicit>();
                         var ddbind = teacher.ddbinds.Find(x => x.userid.Equals($"{dingDingBind.userid}") && x.unionid.Equals($"{dingDingBind.unionid}"));
                         if (ddbind != null)
                         {
@@ -403,21 +398,19 @@ namespace TEAMModeBI.Controllers
                         {
                             if (teacher.id.Equals(temp_id))
                             {
-                                var infourl = _configuration.GetValue<string>("HaBookAuth:CoreAPI");
                                 var clientID = _configuration.GetValue<string>("HaBookAuth:CoreService:clientID");
-                                var clientSecret = _configuration.GetValue<string>("HaBookAuth:CoreService:clientSecret");
                                 var location = _option.Location;
-                                (int code, string temp_content) = await _aoreAPIHttpService.Implicit(clientID, clientSecret, location, $"{infourl}/oauth2/implicit", new Dictionary<string, string>()
-                                {
-                                    { "grant_type", "implicit" },
-                                    { "client_id",clientID },
-                                    { "account",teacher.id },
-                                    { "nonce",Guid.NewGuid().ToString()}
-                                });
+                                implicit_token  = await _aoreAPIHttpService.Implicit(
+                                    new Dictionary<string, string>()
+                                    {
+                                        { "grant_type", "implicit" },
+                                        { "client_id",clientID },
+                                        { "account",teacher.id },
+                                        { "nonce",Guid.NewGuid().ToString()}
+                                    }, location, _configuration);
 
-                                if (!string.IsNullOrEmpty(temp_content) && code == 200)
+                                if (implicit_token!=null)
                                 {
-                                    implicit_token = temp_content.ToObject<TmdidImplicit>();
                                     var ddbind = teacher.ddbinds.Find(x => x.userid.Equals($"{ddbinds.userid}") && x.unionid.Equals($"{ddbinds.unionid}"));
                                     if (ddbind == null)
                                     {
@@ -762,23 +755,19 @@ namespace TEAMModeBI.Controllers
                 teacher = await client.GetContainer(Constant.TEAMModelOS, "Teacher").ReadItemAsync<Teacher>($"{id}", new PartitionKey("Base"));
                 var auth_token = "";
 
-                var url = _configuration.GetValue<string>("HaBookAuth:CoreAPI");
                 var clientID = _configuration.GetValue<string>("HaBookAuth:CoreService:clientID");
-                var clientSecret = _configuration.GetValue<string>("HaBookAuth:CoreService:clientSecret");
-                var logintion = _option.Location;
-                //隐式登录
-                (int code, string content) = await _aoreAPIHttpService.Implicit(clientID, clientSecret, logintion, $"{url}/oauth2/implicit",
+                var location = _option.Location;
+                TmdidImplicit implicit_token = await _aoreAPIHttpService.Implicit(
                     new Dictionary<string, string>()
                     {
-                            { "grant_type", "implicit" },
-                            { "client_id",clientID},
-                            { "account",teacher.id},
-                            { "nonce",Guid.NewGuid().ToString()}
-                    });
+                                        { "grant_type", "implicit" },
+                                        { "client_id",clientID },
+                                        { "account",teacher.id },
+                                        { "nonce",Guid.NewGuid().ToString()}
+                    }, location, _configuration);
 
                 Dictionary<string, object> dic = new Dictionary<string, object> { { "PartitionKey", "authority-bi" } };//设置只访问BI的权限
                 List<Authority> authorityBIList = await _azureStorage.FindListByDict<Authority>(dic);  //获取权限列表
-                TmdidImplicit implicit_token = new TmdidImplicit();
 
                 List<string> roles = new List<string>();//角色列表
                 List<string> permissions = new List<string>();//权限列表
@@ -786,10 +775,8 @@ namespace TEAMModeBI.Controllers
                 School school_base = new School();
                 string school_code = null;
 
-                if (!string.IsNullOrEmpty(content) && code == 200)
+                if (implicit_token!=null)
                 {
-                    implicit_token = content.ToObject<TmdidImplicit>();
-
 
                     if (teacher.defaultSchool != null)
                     {
@@ -910,12 +897,6 @@ namespace TEAMModeBI.Controllers
             public string userid { get; set; }
         }
 
-        public record TmdidImplicit
-        {
-            public string id_token { get; set; }
-            public string access_token { get; set; }
-            public string expires_in { get; set; }
-            public string token_type { get; set; }
-        }
+       
     }
 }