blob: 9d9b9446cb5d6f00720ce3c1f9b76ffb44a9877b (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
namespace I2R.Storage.Api.Models;
public class LoggedInUserModel
{
public LoggedInUserModel() { }
public LoggedInUserModel(ClaimsPrincipal user) {
Username = user.FindFirstValue(AppClaims.USERNAME);
Id = user.FindFirstValue(AppClaims.USER_ID).AsGuid();
Role = UserRole.FromString(user.FindFirstValue(AppClaims.USER_ROLE));
}
public string Username { get; set; }
public Guid Id { get; set; }
public EUserRole Role { get; set; }
public class Public
{
public string Id { get; set; }
public string Username { get; set; }
public string Role { get; set; }
}
public static Public ForThePeople(HttpContext httpContext) {
return new Public() {
Id = httpContext.User.FindFirstValue(AppClaims.USER_ID),
Username = httpContext.User.FindFirstValue(AppClaims.USERNAME),
Role = httpContext.User.FindFirstValue(AppClaims.USER_ROLE)
};
}
}
|