using System.Security.Claims; using DrinkRateAPI.ApiModels.UserProfile; using DrinkRateAPI.Services; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; namespace DrinkRateAPI.Controllers; [ApiController] [Route("userProfile")] public class UserProfileController : ControllerBase { private readonly ILogger _logger; private readonly UserProfileService _userProfileService; public UserProfileController(ILogger logger, UserProfileService userProfileService) { _logger = logger; _userProfileService = userProfileService; } [HttpPut] public UserProfileGet PutUserProfile([FromBody] UserProfilePut userProfile) { throw new ApplicationException(); var x = User.FindFirst(ClaimTypes.NameIdentifier)?.Value; //HttpContext.User.Identities.First(); return new(); } [HttpPut("{userId}/adminStatus")] [Authorize(Policy = "AdminOnly")] [Produces("application/json")] public async Task PutUserAdminStatus(string userId, [FromBody] UserProfileAdminStatusPut body) { var changedProfile = await _userProfileService.PutUserProfileAdminStatusAsync(userId, body.ChangeStatusTo); return Ok(changedProfile); } }