From ee1b2b5b100268aa510257a1a2cd4cd03f9fc72b Mon Sep 17 00:00:00 2001 From: crupest Date: Thu, 12 Nov 2020 21:38:43 +0800 Subject: ... --- BackEnd/Timeline/Models/Http/UserInfo.cs | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) (limited to 'BackEnd/Timeline/Models/Http/UserInfo.cs') diff --git a/BackEnd/Timeline/Models/Http/UserInfo.cs b/BackEnd/Timeline/Models/Http/UserInfo.cs index d92a12c4..26b04e90 100644 --- a/BackEnd/Timeline/Models/Http/UserInfo.cs +++ b/BackEnd/Timeline/Models/Http/UserInfo.cs @@ -2,7 +2,9 @@ using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.Infrastructure; using Microsoft.AspNetCore.Mvc.Routing; +using System.Collections.Generic; using Timeline.Controllers; +using Timeline.Services; namespace Timeline.Models.Http { @@ -27,6 +29,12 @@ namespace Timeline.Models.Http /// True if the user is a administrator. /// public bool? Administrator { get; set; } = default!; +#pragma warning disable CA2227 // Collection properties should be read only + /// + /// The permissions of the user. + /// + public List Permissions { get; set; } = default!; +#pragma warning restore CA2227 // Collection properties should be read only #pragma warning disable CA1707 // Identifiers should not contain underscores /// /// Related links. @@ -54,6 +62,14 @@ namespace Timeline.Models.Http public string Timeline { get; set; } = default!; } + public class UserPermissionsValueConverter : ITypeConverter> + { + public List Convert(UserPermissions source, List destination, ResolutionContext context) + { + return source.ToStringList(); + } + } + public class UserInfoLinksValueResolver : IValueResolver { private readonly IActionContextAccessor _actionContextAccessor; @@ -84,7 +100,10 @@ namespace Timeline.Models.Http { public UserInfoAutoMapperProfile() { - CreateMap().ForMember(u => u._links, opt => opt.MapFrom()); + CreateMap>() + .ConvertUsing(); + CreateMap() + .ForMember(u => u._links, opt => opt.MapFrom()); } } } -- cgit v1.2.3