summaryrefslogtreecommitdiffstats
path: root/src/server/Api/V1/BaseV1Route.cs
blob: ba7d9789f6051029a5e65f9eb82d8edef40564ff (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
namespace IOL.BookmarkThing.Server.Api.V1;

/// <inheritdoc />
[Authorize(AuthenticationSchemes = AuthSchemes)]
[ApiController]
public class BaseV1Route : ControllerBase
{
	private const string AuthSchemes = CookieAuthenticationDefaults.AuthenticationScheme + "," + Constants.BASIC_AUTH_SCHEME;

	/// <summary>
	/// User data for the currently logged on user.
	/// </summary>
	protected LoggedInV1User LoggedInUser => new() {
			Username = User.Identity?.Name,
			Id = User.Claims.SingleOrDefault(c => c.Type == ClaimTypes.NameIdentifier)?.Value.ToGuid() ?? default
	};
}