|
@@ -248,7 +248,7 @@ namespace HiTeachCC.Service.Core.Implement
|
|
throw new Exception("Validation failure,user is null !");
|
|
throw new Exception("Validation failure,user is null !");
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- public JwtResponse CreateJwtToken(LoginInfo login ,string tiket)
|
|
|
|
|
|
+ public JwtResponse CreateJwtToken(LoginInfo login, string tiket)
|
|
{
|
|
{
|
|
ClaimModel model = new ClaimModel
|
|
ClaimModel model = new ClaimModel
|
|
{
|
|
{
|
|
@@ -275,12 +275,12 @@ namespace HiTeachCC.Service.Core.Implement
|
|
string authorizationCode = HttpContextHelper.GetAuthorizationCode(httpContextAccessor, "");
|
|
string authorizationCode = HttpContextHelper.GetAuthorizationCode(httpContextAccessor, "");
|
|
if (string.IsNullOrEmpty(authorizationCode))
|
|
if (string.IsNullOrEmpty(authorizationCode))
|
|
{
|
|
{
|
|
- if (string.IsNullOrEmpty(ticketInfo.Ticket))
|
|
|
|
|
|
+ if (ticketInfo != null && string.IsNullOrEmpty(ticketInfo.Ticket))
|
|
{
|
|
{
|
|
throw new BizException(401, "Unauthorized");
|
|
throw new BizException(401, "Unauthorized");
|
|
}
|
|
}
|
|
- // string code = BCryptHelper.Ecrypt(ticketInfo.Ticket + ticketInfo.TeamModelId);
|
|
|
|
- // bool f = BCryptHelper.Verify(ticketInfo.Ticket + ticketInfo.TeamModelId, ticketInfo.Sign);
|
|
|
|
|
|
+ // string code = BCryptHelper.Ecrypt(ticketInfo.Ticket + ticketInfo.TeamModelId);
|
|
|
|
+ // bool f = BCryptHelper.Verify(ticketInfo.Ticket + ticketInfo.TeamModelId, ticketInfo.Sign);
|
|
LoginInfo login = FindOneByKey<LoginInfo>("Ticket", ticketInfo.Ticket).Result;
|
|
LoginInfo login = FindOneByKey<LoginInfo>("Ticket", ticketInfo.Ticket).Result;
|
|
if (login != null && !string.IsNullOrEmpty(login.Token))
|
|
if (login != null && !string.IsNullOrEmpty(login.Token))
|
|
{
|
|
{
|
|
@@ -289,53 +289,55 @@ namespace HiTeachCC.Service.Core.Implement
|
|
await Update<LoginInfo>(login);
|
|
await Update<LoginInfo>(login);
|
|
return token;
|
|
return token;
|
|
}
|
|
}
|
|
-
|
|
|
|
- ///不验证TmdID
|
|
|
|
- #region
|
|
|
|
- /*
|
|
|
|
- LoginInfo loginInfo = new LoginInfo
|
|
|
|
|
|
+ // LoginInfo loginInfo = new LoginInfo
|
|
|
|
+ // {
|
|
|
|
+ // PartitionKey = "loginInfo",
|
|
|
|
+ // // Phone = response.result.cellphone,
|
|
|
|
+ // RowKey = Guid.NewGuid().ToString(),
|
|
|
|
+ // TeamModelId = ticketInfo.TeamModelId,
|
|
|
|
+ // Name = ticketInfo.Name,
|
|
|
|
+ // Ticket = ticketInfo.Ticket,
|
|
|
|
+ // //CountryCode = response.result.countryCode
|
|
|
|
+ // };
|
|
|
|
+ // TeamModelUser user = await FindOneByKey<TeamModelUser>("TeamModelId", ticketInfo.TeamModelId);
|
|
|
|
+ // if (user == null || string.IsNullOrEmpty(user.RowKey))
|
|
|
|
+ // {
|
|
|
|
+ // user = new TeamModelUser { RowKey = Guid.NewGuid().ToString(), PartitionKey ="userInfo", RegisterTime = DateTimeHelper.ConvertToTimeStamp13(DateTime.Now) };
|
|
|
|
+ // }
|
|
|
|
+ //// user.Cellphone = response.result.cellphone;
|
|
|
|
+ // user.NickName = ticketInfo.Name;
|
|
|
|
+ // if (string.IsNullOrEmpty(user.FullName))
|
|
|
|
+ // {
|
|
|
|
+ // user.FullName = ticketInfo.Name;
|
|
|
|
+ // }
|
|
|
|
+ // user.TeamModelId = ticketInfo.TeamModelId;
|
|
|
|
+ // //user.PhoneCode = response.result.countryCode;
|
|
|
|
+ // JwtResponse jwtToken = CreateJwtToken(loginInfo, ticketInfo.Ticket);
|
|
|
|
+ // loginInfo.Token = jwtToken.Access_token;
|
|
|
|
+ // loginInfo.Scope = jwtToken.Scope;
|
|
|
|
+ // await Save<LoginInfo>(loginInfo);
|
|
|
|
+ // await SaveOrUpdate<TeamModelUser>(user);
|
|
|
|
+ // return jwtToken;
|
|
|
|
+ string jwttoken = ticketInfo.Token.Replace("Bearer ", "");
|
|
|
|
+ Dictionary<string, string> headers = new Dictionary<string, string>
|
|
{
|
|
{
|
|
- PartitionKey = "15283771540",
|
|
|
|
- Phone = "15283771540",
|
|
|
|
- RowKey = Guid.NewGuid().ToString(),
|
|
|
|
- TeamModelId = ticketInfo.TeamModelId,
|
|
|
|
- Name = ticketInfo.Name,
|
|
|
|
- Ticket = ticketInfo.Ticket,
|
|
|
|
- CountryCode = "86"
|
|
|
|
|
|
+ { Constants.AUTHORIZATION,"Bearer "+jwttoken },
|
|
};
|
|
};
|
|
- TeamModelUser user = await FindOneByKey<TeamModelUser>("TeamModelId", ticketInfo.TeamModelId);
|
|
|
|
- if (user == null || string.IsNullOrEmpty(user.RowKey))
|
|
|
|
- {
|
|
|
|
- user = new TeamModelUser { RowKey = Guid.NewGuid().ToString(), PartitionKey = loginInfo.CountryCode, registerTime = DateTimeHelper.ConvertToTimeStamp13(DateTime.Now) };
|
|
|
|
- }
|
|
|
|
- user.cellphone = "15283771540";
|
|
|
|
- user.nickname = ticketInfo.Name;
|
|
|
|
- if (string.IsNullOrEmpty(user.fullName))
|
|
|
|
- {
|
|
|
|
- user.fullName = ticketInfo.Name;
|
|
|
|
- }
|
|
|
|
- user.teamModelId = ticketInfo.TeamModelId;
|
|
|
|
- user.phoneCode = "86";
|
|
|
|
- JwtResponse jwtToken = CreateJwtToken(loginInfo);
|
|
|
|
- loginInfo.Token = jwtToken.Access_token;
|
|
|
|
- loginInfo.Scope = jwtToken.Scope;
|
|
|
|
- await Save<LoginInfo>(loginInfo);
|
|
|
|
- await SaveOrUpdate<TeamModelUser>(user);
|
|
|
|
- return jwtToken;
|
|
|
|
- */
|
|
|
|
- #endregion
|
|
|
|
JosnRPCRequest<Dictionary<string, object>> request = new JosnRPCRequest<Dictionary<string, object>>
|
|
JosnRPCRequest<Dictionary<string, object>> request = new JosnRPCRequest<Dictionary<string, object>>
|
|
{
|
|
{
|
|
- method = "UserInfo"
|
|
|
|
|
|
+ method = "UserInfoManage"
|
|
};
|
|
};
|
|
-
|
|
|
|
|
|
+
|
|
Dictionary<string, object> ticket = new Dictionary<string, object>
|
|
Dictionary<string, object> ticket = new Dictionary<string, object>
|
|
{
|
|
{
|
|
- { "ticket", ticketInfo.Ticket }
|
|
|
|
|
|
+ { "idToken",ticketInfo.Ticket },
|
|
|
|
+ { "method", "get" },
|
|
|
|
+ { "option", "userInfo"},
|
|
|
|
+ { "extraInfo", new object() }
|
|
};
|
|
};
|
|
request.@params = ticket;
|
|
request.@params = ticket;
|
|
string data = MessagePackHelper.ObjectToJson(request);
|
|
string data = MessagePackHelper.ObjectToJson(request);
|
|
- string jsonStr = _httpClientService.HttpPost(ticketInfo.ServiceUrl+ "/account", data, Constants.CONTENT_TYPE_JSON, Encoding.UTF8);
|
|
|
|
|
|
+ string jsonStr = HttpHelper.HttpPost(BaseConfigModel.Configuration["HaBookAuth:AccountUrl"], data, headers, Constants.CONTENT_TYPE_JSON,1000, Encoding.UTF8);
|
|
if (!string.IsNullOrEmpty(jsonStr))
|
|
if (!string.IsNullOrEmpty(jsonStr))
|
|
{
|
|
{
|
|
JosnRPCResponse<TeamModelIdInfo> response = MessagePackHelper.JsonToObject<JosnRPCResponse<TeamModelIdInfo>>(jsonStr);
|
|
JosnRPCResponse<TeamModelIdInfo> response = MessagePackHelper.JsonToObject<JosnRPCResponse<TeamModelIdInfo>>(jsonStr);
|
|
@@ -344,27 +346,27 @@ namespace HiTeachCC.Service.Core.Implement
|
|
LoginInfo loginInfo = new LoginInfo
|
|
LoginInfo loginInfo = new LoginInfo
|
|
{
|
|
{
|
|
PartitionKey = response.result.cellphone,
|
|
PartitionKey = response.result.cellphone,
|
|
- Phone = response.result.cellphone,
|
|
|
|
RowKey = Guid.NewGuid().ToString(),
|
|
RowKey = Guid.NewGuid().ToString(),
|
|
TeamModelId = response.result.id,
|
|
TeamModelId = response.result.id,
|
|
Name = response.result.name,
|
|
Name = response.result.name,
|
|
Ticket = ticketInfo.Ticket,
|
|
Ticket = ticketInfo.Ticket,
|
|
- CountryCode = response.result.countryCode
|
|
|
|
};
|
|
};
|
|
TeamModelUser user = await FindOneByKey<TeamModelUser>("TeamModelId", response.result.id);
|
|
TeamModelUser user = await FindOneByKey<TeamModelUser>("TeamModelId", response.result.id);
|
|
if (user == null || string.IsNullOrEmpty(user.RowKey))
|
|
if (user == null || string.IsNullOrEmpty(user.RowKey))
|
|
{
|
|
{
|
|
- user = new TeamModelUser { RowKey = Guid.NewGuid().ToString(), PartitionKey = loginInfo.CountryCode, RegisterTime = DateTimeHelper.ConvertToTimeStamp13(DateTime.Now) };
|
|
|
|
|
|
+ user = new TeamModelUser { RowKey = Guid.NewGuid().ToString(), PartitionKey = response.result.countryCode, RegisterTime = DateTimeHelper.ConvertToTimeStamp13(DateTime.Now) };
|
|
}
|
|
}
|
|
user.Cellphone = response.result.cellphone;
|
|
user.Cellphone = response.result.cellphone;
|
|
- user.NickName = response.result.name;
|
|
|
|
|
|
+ user.FullName= response.result.name;
|
|
|
|
+ user.NickName = response.result.nickname;
|
|
|
|
+ user.HeadImgUrl = response.result.profilePicture;
|
|
if (string.IsNullOrEmpty(user.FullName))
|
|
if (string.IsNullOrEmpty(user.FullName))
|
|
{
|
|
{
|
|
user.FullName = response.result.name;
|
|
user.FullName = response.result.name;
|
|
}
|
|
}
|
|
user.TeamModelId = response.result.id;
|
|
user.TeamModelId = response.result.id;
|
|
user.PhoneCode = response.result.countryCode;
|
|
user.PhoneCode = response.result.countryCode;
|
|
- JwtResponse jwtToken = CreateJwtToken(loginInfo,ticketInfo.Ticket);
|
|
|
|
|
|
+ JwtResponse jwtToken = CreateJwtToken(loginInfo, ticketInfo.Ticket);
|
|
loginInfo.Token = jwtToken.Access_token;
|
|
loginInfo.Token = jwtToken.Access_token;
|
|
loginInfo.Scope = jwtToken.Scope;
|
|
loginInfo.Scope = jwtToken.Scope;
|
|
await Save<LoginInfo>(loginInfo);
|
|
await Save<LoginInfo>(loginInfo);
|