|
@@ -52,9 +52,9 @@ namespace TEAMModelOS.Service.Common.Implements
|
|
|
if (login != null && !string.IsNullOrEmpty(login.Token))
|
|
|
{
|
|
|
result.CheckTicket = true;
|
|
|
- string token = CreateJwtToken(login);
|
|
|
+ JwtResponse token = CreateJwtToken(login);
|
|
|
result.JwtToken = token;
|
|
|
- login.Token = token;
|
|
|
+ login.Token = token.Access_token;
|
|
|
await _repository.Update<LoginInfo>(login);
|
|
|
return result;
|
|
|
}
|
|
@@ -78,8 +78,6 @@ namespace TEAMModelOS.Service.Common.Implements
|
|
|
JosnRPCResponse<TeamModelIdInfo> response = MessagePackHelper.JsonToObject<JosnRPCResponse<TeamModelIdInfo>>(jsonStr);
|
|
|
if (response.error == null && response != null)
|
|
|
{
|
|
|
-
|
|
|
-
|
|
|
result.CheckTicket = true;
|
|
|
LoginInfo loginInfo = new LoginInfo
|
|
|
{
|
|
@@ -91,10 +89,23 @@ namespace TEAMModelOS.Service.Common.Implements
|
|
|
Ticket = ticketInfo.Ticket,
|
|
|
CountryCode = response.result.countryCode
|
|
|
};
|
|
|
- string jwtToken = CreateJwtToken(loginInfo);
|
|
|
- loginInfo.Token = jwtToken;
|
|
|
+ TeamModelUser user= await _repository.FindOneByKey<TeamModelUser>("TeamModelId", response.result.id);
|
|
|
+ if (user == null || string.IsNullOrEmpty(user.RowKey))
|
|
|
+ {
|
|
|
+ user = new TeamModelUser { RowKey = Guid.NewGuid().ToString(), PartitionKey = loginInfo.CountryCode ,RegisterTime=DateTimeHelper.ConvertToTimeStamp13(DateTime.Now) };
|
|
|
+ }
|
|
|
+ user.Cellphone = response.result.cellphone;
|
|
|
+ user.NickName = response.result.name;
|
|
|
+ if (string.IsNullOrEmpty(user.FullName)) {
|
|
|
+ user.FullName = response.result.name;
|
|
|
+ }
|
|
|
+ user.TeamModelId = response.result.id;
|
|
|
+ user.CountryCode = response.result.countryCode;
|
|
|
+ JwtResponse jwtToken = CreateJwtToken(loginInfo);
|
|
|
+ loginInfo.Token = jwtToken.Access_token;
|
|
|
result.JwtToken = jwtToken;
|
|
|
- SaveLoginInfoAsync(loginInfo);
|
|
|
+ await _repository.Save<LoginInfo>(loginInfo);
|
|
|
+ await _repository.SaveOrUpdate<TeamModelUser>(user);
|
|
|
return result;
|
|
|
}
|
|
|
else
|
|
@@ -125,14 +136,14 @@ namespace TEAMModelOS.Service.Common.Implements
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- Dictionary<string, Object> msp = new Dictionary<string, object>
|
|
|
+ Dictionary<string, object> msp = new Dictionary<string, object>
|
|
|
{
|
|
|
{ "Token", ticketInfo.Token }
|
|
|
};
|
|
|
LoginInfo loginInfo = _repository.FindOneByDict<LoginInfo>(msp).Result;
|
|
|
if (loginInfo != null && !string.IsNullOrEmpty(loginInfo.Token))
|
|
|
{
|
|
|
- return new LoginResult { JwtToken = loginInfo.Token, CheckTicket = true };
|
|
|
+ return new LoginResult { JwtToken = new JwtResponse { Access_token=loginInfo.Token ,Scope=loginInfo.Scope}, CheckTicket = true };
|
|
|
}
|
|
|
else
|
|
|
{
|
|
@@ -140,11 +151,8 @@ namespace TEAMModelOS.Service.Common.Implements
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- public string CreateJwtToken(LoginInfo loginInfo)
|
|
|
+ public JwtResponse CreateJwtToken(LoginInfo loginInfo)
|
|
|
{
|
|
|
- //List<ContestRoleUser> roots = BaseConfigModel.GetAppSettings<List<ContestRoleUser>>("RoleUser:Root");
|
|
|
- //List<ContestRoleUser> admins = BaseConfigModel.GetAppSettings<List<ContestRoleUser>>("RoleUser:Admin");
|
|
|
-
|
|
|
List<RoleUser> roots = BaseConfigModel.Configuration.GetSection("RoleUser:Root").Get<List<RoleUser>>();
|
|
|
List<RoleUser> admins = BaseConfigModel.Configuration.GetSection("RoleUser:Admin").Get<List<RoleUser>>();
|
|
|
string role = "";
|
|
@@ -174,12 +182,12 @@ namespace TEAMModelOS.Service.Common.Implements
|
|
|
model.Claims.Add(new Claim(JwtClaimTypes.PhoneNumber, loginInfo.Phone));
|
|
|
model.Roles.Add(role);
|
|
|
JwtResponse jwtResponse = JwtHelper.IssueJWT(model, _options.Value);
|
|
|
- return jwtResponse.access_token;
|
|
|
+ return jwtResponse;
|
|
|
}
|
|
|
|
|
|
- public LoginInfo SaveLoginInfoAsync(LoginInfo loginInfo)
|
|
|
+ public Task<LoginInfo> SaveLoginInfoAsync(LoginInfo loginInfo)
|
|
|
{
|
|
|
- return _repository.Save<LoginInfo>(loginInfo).Result;
|
|
|
+ return _repository.Save<LoginInfo>(loginInfo);
|
|
|
}
|
|
|
}
|
|
|
}
|