aboutsummaryrefslogtreecommitdiffstats
path: root/code/api/src/Endpoints/EndpointBase.cs
blob: a2f55a6f0b61164da7c5f5e2cae03f0f8b67afab (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
namespace IOL.GreatOffice.Api.Endpoints;

public class EndpointBase : ControllerBase
{
    /// <summary>
    /// User data for the currently logged on user.
    /// </summary>
    protected LoggedInUserModel LoggedInUser => new() {
        Username = User.FindFirstValue(AppClaims.NAME),
        Id = User.FindFirstValue(AppClaims.USER_ID).AsGuid(),
    };

    public ActionResult KnownProblem(string title = default, string subtitle = default, Dictionary<string, string> errors = default) {
        return BadRequest(new KnownProblemModel {
            Title = title,
            Subtitle = subtitle,
            Errors = errors,
            TraceId = HttpContext.TraceIdentifier
        });
    }
}