优化登出接口
This commit is contained in:
@@ -86,6 +86,26 @@ namespace WMS.Web.Domain.Services.Public
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<Result<string>> Init1()
|
||||
{
|
||||
BasicHttpBinding binding = new BasicHttpBinding();
|
||||
binding.MaxReceivedMessageSize = int.MaxValue;
|
||||
binding.SendTimeout = new TimeSpan(int.MaxValue);
|
||||
EndpointAddress address = new EndpointAddress(this._erpOptions.EndpointAddress);
|
||||
this._client = new ERPGWSoapClient(binding, address);
|
||||
try
|
||||
{
|
||||
var result = await this._client.ValidateSystemAsync(this._erpOptions.UserName, this._erpOptions.Password, "Orico", "");
|
||||
if (result == null)
|
||||
return Result<string>.ReFailure(ResultCodes.Erp_Login_Error);
|
||||
return Result<string>.ReSuccess(result.AccessToken);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return Result<string>.ReFailure(ResultCodes.Erp_Login_Error);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查单据类型的值
|
||||
/// </summary>
|
||||
@@ -95,7 +115,7 @@ namespace WMS.Web.Domain.Services.Public
|
||||
try
|
||||
{
|
||||
//1.先登录金蝶-拿到token
|
||||
var token_result = await this.Init();
|
||||
var token_result = await this.Init1();
|
||||
if (!token_result.IsSuccess)
|
||||
return ResultList<ErpBaseDto>.ReFailure(token_result);
|
||||
|
||||
|
||||
@@ -462,7 +462,7 @@ namespace WMS.Web.Domain.Services.Public
|
||||
reqData.Add("app_id", _soaOptions.AppId);
|
||||
reqData.Add("app_secret", _soaOptions.AppSecret);
|
||||
reqData.Add("access_token", dto.AccessToken);
|
||||
string result = _httpClientHelp.PostHttp(_soaOptions.Url + "/uc/authorize/signin_out", reqData, true, dto.SessionId);
|
||||
string result = _httpClientHelp.PostHttp(_soaOptions.Url_V3 + "/uc/authorize/signin_out", reqData, true, dto.SessionId);
|
||||
_logger.LogInformation("退出登录返回:" + result);
|
||||
var jObject = JsonObject.Parse(result);
|
||||
if (jObject["errno"] == 0)
|
||||
@@ -477,6 +477,32 @@ namespace WMS.Web.Domain.Services.Public
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 登录退出
|
||||
/// </summary>
|
||||
/// <param name="dto"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<Result> LoginOut(LoginOutDto dto)
|
||||
{
|
||||
//2.请求PHP单点登出接口
|
||||
var reqData = new LoginOutAuthorizeRequest();
|
||||
reqData.AccessToken = dto.AccessToken;
|
||||
reqData.RefreshToken = dto.RefreshToken;
|
||||
string result = _httpClientHelp.GetHttpOut(_soaOptions.Url_V3 + "/uc/logout", reqData);
|
||||
_logger.LogInformation("退出登录返回:" + result);
|
||||
var jObject = JsonObject.Parse(result);
|
||||
if (jObject["code"] == 0)
|
||||
{
|
||||
//设置本地token的缓存:为黑名单的token做存储
|
||||
await CacheOutToken(dto);
|
||||
return Result.ReSuccess();
|
||||
}
|
||||
else
|
||||
{
|
||||
return Result.ReFailure(BaseResultCodes.UnAuthorized);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 刷新token
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user