Add project files.

This commit is contained in:
2023-04-29 09:17:17 +03:00
commit 62178f1f32
493 changed files with 45863 additions and 0 deletions
@@ -0,0 +1,26 @@
namespace MyOffice.Web.Controllers;
using System.Security.Authentication;
using Core.Extensions;
using IdentityModel;
using Microsoft.AspNetCore.Mvc;
using static IdentityServer4.Models.IdentityResources;
public class BaseApiController : ControllerBase
{
public Guid UserId
{
get
{
var subject = User.Claims.FirstOrDefault(x => x.Type == JwtClaimTypes.Subject)?.Value;
if (subject.IsPresent() && Guid.TryParse(subject, out var guid)) return guid;
throw new AuthenticationException("Get UserId failed");
}
}
public ObjectResult ProblemBadRequest(string? detail = null)
{
return Problem(detail, statusCode: StatusCodes.Status400BadRequest);
}
}