diff --git a/FCL/BLL/APIService/SyncUserInfoService.cs b/FCL/BLL/APIService/SyncUserInfoService.cs index 57988e6..90612d5 100644 --- a/FCL/BLL/APIService/SyncUserInfoService.cs +++ b/FCL/BLL/APIService/SyncUserInfoService.cs @@ -30,12 +30,12 @@ namespace BLL.APIService } public static void GetSyncUserInfo() { - var token = GetUserToken(); //获取接口token + //var token = GetUserToken(); //获取接口token var dic = GetDepartList(); //把本地数据库中的部门全部取出作为字典 var dicUser = GetUserInfoByAccount(); //同上把所有用户取出来 - //string file = System.Web.HttpContext.Current.Server.MapPath("~/data.txt"); - //string result = System.IO.File.ReadAllText(file); - string result = BLL.Common.HttpHelper.HttpPostRequest(GETHRINfOAPI, "", token); + string file = System.Web.HttpContext.Current.Server.MapPath("~/data.txt"); + string result = System.IO.File.ReadAllText(file); + //string result = BLL.Common.HttpHelper.HttpPostRequest(GETHRINfOAPI, "", token); var data = JsonHelper.DeserializeJsonToObject>>(result); List logList = new List(); if (data.code == "200") @@ -246,7 +246,7 @@ namespace BLL.APIService /// private static Dictionary GetUserInfoByAccount() { - return BLL.Funs.DB.Sys_User.Select(t => new { t.UserId, t.Account }).ToList() + return BLL.Funs.DB.Sys_User.Where(t=>t.IsPost==true).Select(t => new { t.UserId, t.Account }).ToList() .ToDictionary(t => t.Account.ToLower(), t => t.UserId); } diff --git a/FCL/FineUIPro.Web/ssocallback.aspx.cs b/FCL/FineUIPro.Web/ssocallback.aspx.cs index c81ac9a..2e92b2e 100644 --- a/FCL/FineUIPro.Web/ssocallback.aspx.cs +++ b/FCL/FineUIPro.Web/ssocallback.aspx.cs @@ -16,20 +16,24 @@ namespace FineUIPro.Web protected void Page_Load(object sender, EventArgs e) { this.code = Request.Params["code"]; - if (string.IsNullOrEmpty(this.code)) + BLL.ErrLogInfo.WriteLog($"获取code={this.code}"); + if (!IsPostBack) { - Response.Redirect("~/login.aspx"); - return; - } - var token= GetAccessToken(this.code); - var userInfo = getUserInfo(token); - if (userInfo == null) - { - Response.Redirect("~/login.aspx"); - return; - } + if (string.IsNullOrEmpty(this.code)) + { + Response.Redirect("~/login.aspx"); + return; + } + var token = GetAccessToken(this.code); + var userInfo = getUserInfo(token); + if (userInfo == null) + { + Response.Redirect("~/login.aspx"); + return; + } - Response.Redirect("~/index.aspx"); + Response.Redirect("~/index.aspx"); + } } private AccessTokenModel GetAccessToken(string _code) @@ -39,18 +43,18 @@ namespace FineUIPro.Web string grant_type = "authorization_code"; string redirect_url = "http://localhost:6166/ssocallback.aspx"; string scope = "profile openid"; - string baseUrl = $" https://login.microsoftonline.com/ecaa386b-c8df-4ce0-ad01740cbdb5ba55/oauth2/v2.0/token"; + string baseUrl = $"https://login.microsoftonline.com/ecaa386b-c8df-4ce0-ad01740cbdb5ba55/oauth2/v2.0/token"; try { string postData = $"code={code}&client_id={clientId}&client_secret={clientSecret}&grant_type={grant_type}&redirect_uri={redirect_url}&scope={scope}"; - string result = BLL.Common.HttpHelper.HttpPostRequest(baseUrl, postData, string.Empty); + BLL.ErrLogInfo.WriteLog($"参数url={postData}"); + BLL.ErrLogInfo.WriteLog($"===================================="); + BLL.ErrLogInfo.WriteLog($"结果Result={result}"); var Data = JsonConvert.DeserializeObject(result); - return Data; - } catch (Exception ex) { @@ -67,13 +71,11 @@ namespace FineUIPro.Web try { var result = HttpHelper.HttpGetRequest(baseUrl, token.access_token); - if (result.IndexOf("sub") > -1) { var info = JsonConvert.DeserializeObject(result); //写入session信息 - //写入cookie信息 - + Session["ossInfo"] = info; return info; }