Mam dwa serwisy
Core oraz Identity
Core ma jwtmiddleware w ktorym mam taki kod
private async void AttachUserToContext(HttpContext context, string token)
{
try
{
var response = await _httpClient.PostAsync($"authentication/authenticate?token={token}",
new StringContent(""));
var responseContent = await response.Content.ReadAsStringAsync();
var userPayload = JsonConvert.DeserializeObject<UserResponse>(responseContent);
context.Items["UserId"] = userPayload.Id;
}
...
}
wszystko swietnie, ale chcialbym zapisac gdzies ta informacje, bo dalej idzie request do controllera w ktorym to UserId bym z checia uzyl
probowalem roznych sposobow, ale glownym problemem jest brak HttpContext property w controllerze
[ExtendObjectType(Name = "Mutation")]
public class UserMutation
{
[Authorize]
[GraphQLType(typeof(EitherUnionType<Error, VoidResponse>))]
public async Task<object> ChangeNickname(
UserInputNickname userInputNickname,
[Service] IUserAccountService userAccountService)
{
var result = await userAccountService.ChangeNickname(userID, userInputNickname);
return result.Unwrap();
}
}
np tutaj chcialbym miec to userID ktore odczytuje w middleware.
pomysly jakies?