2112
This commit is contained in:
parent
4dc89c8561
commit
25bfa4fa71
|
@ -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<ResultData<List<UserInfo>>>(result);
|
||||
List<Model.SyncDataUserLogs> logList = new List<Model.SyncDataUserLogs>();
|
||||
if (data.code == "200")
|
||||
|
@ -246,7 +246,7 @@ namespace BLL.APIService
|
|||
/// <returns></returns>
|
||||
private static Dictionary<string,string> 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);
|
||||
|
||||
}
|
||||
|
|
|
@ -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<AccessTokenModel>(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<UserTokenModel>(result);
|
||||
//写入session信息
|
||||
//写入cookie信息
|
||||
|
||||
Session["ossInfo"] = info;
|
||||
return info;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue