Skip to content

Replace repeated GetUserId() boilerplate with a ClaimsPrincipal extension or endpoint filter #1606

Open

Description

@BenjaminMichaelis

Controllers repeat if (GetUserId() is not { } userId) return Unauthorized(); after [Authorize] already guarantees authentication, and the same claim lookup is repeated in Program.cs. Add a GetRequiredUserId() extension (or filter) and drop the dead 401 branches.

Found during review of #1267; intentionally kept out of that PR.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions