Skip to content

Commit 6b184a2

Browse files
committed
Merge branch 'dev'
2 parents 5dd7ad9 + d241829 commit 6b184a2

27 files changed

Lines changed: 5160 additions & 837 deletions

src/IdentityManager2/Api/Controllers/MetaController.cs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
using System;
1+
using System;
22
using System.Collections.Generic;
3+
using System.Text.Json.Serialization;
34
using System.Threading.Tasks;
45
using IdentityManager2.Api.Models;
56
using IdentityManager2.Core.Metadata;
@@ -37,9 +38,9 @@ private async Task<IdentityManagerMetadata> GetMetadataAsync()
3738
public async Task<IActionResult> Get()
3839
{
3940
var meta = await GetMetadataAsync();
40-
var data = new Dictionary<string, object> {{"currentUser", new {username = User.Identity.Name}}};
41-
42-
var links = new Dictionary<string, object> {["users"] = Url.Link("GetUsers", null)};
41+
var data = new Dictionary<string, object> { { "currentUser", new AnonymousUserName{ username = User.Identity.Name } } };
42+
43+
var links = new Dictionary<string, object> { ["users"] = Url.Link("GetUsers", null) };
4344

4445
if (meta.RoleMetadata.SupportsListing)
4546
{
@@ -54,7 +55,7 @@ public async Task<IActionResult> Get()
5455
links["createRole"] = new CreateRoleLink(Url, meta.RoleMetadata);
5556
}
5657

57-
return Ok(new
58+
return Ok(new MetaResult
5859
{
5960
Data = data,
6061
Links = links

src/IdentityManager2/Api/Controllers/PageController.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public async Task<IActionResult> Index()
3636
TitleNavBarLinkTarget = this.config.TitleNavBarLinkTarget,
3737
LoginPath = this.config.SecurityConfiguration.LoginPath,
3838
LogoutPath = this.config.SecurityConfiguration.LogoutPath
39-
})
39+
}, PageModelParams_Context.Default.PageModelParams)
4040
});
4141
}
4242

src/IdentityManager2/Api/Controllers/RolesController.cs

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
using System;
1+
using System;
22
using System.Collections.Generic;
33
using System.Linq;
4+
using System.Text.Json;
45
using System.Threading.Tasks;
56
using IdentityManager2.Api.Models;
67
using IdentityManager2.Core;
@@ -15,7 +16,7 @@ namespace IdentityManager2.Api.Controllers
1516
{
1617
[Route(IdentityManagerConstants.RoleRoutePrefix)]
1718
[Authorize(IdentityManagerConstants.IdMgrAuthPolicy)]
18-
[ResponseCache(NoStore=true, Location=ResponseCacheLocation.None)]
19+
[ResponseCache(NoStore = true, Location = ResponseCacheLocation.None)]
1920
public class RolesController : Controller
2021
{
2122
private readonly IIdentityManagerService service;
@@ -67,7 +68,7 @@ public async Task<IActionResult> GetRolesAsync(string filter = null, int start =
6768

6869
// POST
6970
[HttpPost, Route("", Name = IdentityManagerConstants.RouteNames.CreateRole)]
70-
public async Task<IActionResult> CreateRoleAsync([FromBody]PropertyValue[] properties)
71+
public async Task<IActionResult> CreateRoleAsync([FromBody] PropertyValue[] properties)
7172
{
7273
var meta = await GetMetadataAsync();
7374
if (!meta.RoleMetadata.SupportsCreate)
@@ -87,12 +88,12 @@ public async Task<IActionResult> CreateRoleAsync([FromBody]PropertyValue[] prope
8788
var result = await service.CreateRoleAsync(properties);
8889
if (result.IsSuccess)
8990
{
90-
var url = Url.Link(IdentityManagerConstants.RouteNames.GetRole, new { subject = result.Result.Subject });
91+
var url = Url.Link(IdentityManagerConstants.RouteNames.GetRole, new AnonymousSubject { subject = result.Result.Subject });
9192

92-
var resource = new
93+
var resource = new AnonymousCreatedRole
9394
{
94-
Data = new { subject = result.Result.Subject },
95-
Links = new { detail = url }
95+
Data = new AnonymousSubject { subject = result.Result.Subject },
96+
Links = new AnonymousDetail { detail = url }
9697
};
9798
return Created(url, resource);
9899
}
@@ -108,7 +109,7 @@ public async Task<IActionResult> GetRoleAsync(string subject)
108109
{
109110
if (IsNullOrWhiteSpace(subject))
110111
{
111-
ModelState["subject.String"].Errors.Clear();
112+
ModelState["subject.String"]?.Errors.Clear();
112113
ModelState.AddModelError("", Messages.SubjectRequired);
113114
}
114115

@@ -133,8 +134,6 @@ public async Task<IActionResult> GetRoleAsync(string subject)
133134
}
134135

135136
var response = Ok(new RoleDetailResource(result.Result, Url, meta.RoleMetadata));
136-
137-
138137
return response;
139138
}
140139
return BadRequest(result.ToError());
@@ -168,7 +167,7 @@ public async Task<IActionResult> SetPropertyAsync(string subject, string type)
168167
{
169168
if (IsNullOrWhiteSpace(subject))
170169
{
171-
ModelState["subject.String"].Errors.Clear();
170+
ModelState["subject.String"]?.Errors.Clear();
172171
ModelState.AddModelError("", Messages.SubjectRequired);
173172
}
174173

src/IdentityManager2/Api/Controllers/UsersController.cs

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using System;
22
using System.Collections.Generic;
33
using System.Linq;
4+
using System.Text.Json;
45
using System.Threading.Tasks;
56
using IdentityManager2.Api.Models;
67
using IdentityManager2.Core;
@@ -25,7 +26,7 @@ public UsersController(IIdentityManagerService service)
2526
{
2627
this.service = service ?? throw new ArgumentNullException(nameof(service));
2728
}
28-
29+
2930
public async Task<IdentityManagerMetadata> GetMetadataAsync()
3031
{
3132
if (metadata == null)
@@ -74,18 +75,18 @@ public async Task<IActionResult> CreateUserAsync([FromBody] PropertyValue[] prop
7475
var result = await service.CreateUserAsync(properties);
7576
if (result.IsSuccess)
7677
{
77-
var url = Url.Link(IdentityManagerConstants.RouteNames.GetUser, new {subject = result.Result.Subject});
78-
var resource = new
78+
var url = Url.Link(IdentityManagerConstants.RouteNames.GetUser, new AnonymousSubject { subject = result.Result.Subject });
79+
var resource = new AnonymousCreatedUser
7980
{
80-
Data = new {subject = result.Result.Subject},
81-
Links = new {detail = url}
81+
Data = new AnonymousSubject { subject = result.Result.Subject },
82+
Links = new AnonymousDetail { detail = url }
8283
};
8384

8485
return Created(url, resource);
8586
}
8687

8788
ModelState.AddModelError("errors", result.Errors.Aggregate((workingSentence, next) => workingSentence + " " + next));
88-
if(result.Errors.Count > 0)
89+
if (result.Errors.Count > 0)
8990
return BadRequest(ModelState);
9091
}
9192

@@ -97,7 +98,7 @@ public async Task<IActionResult> GetUserAsync(string subject)
9798
{
9899
if (IsNullOrWhiteSpace(subject))
99100
{
100-
ModelState["subject.String"].Errors.Clear();
101+
ModelState["subject.String"]?.Errors.Clear();
101102
ModelState.AddModelError("", Messages.SubjectRequired);
102103
}
103104

@@ -144,7 +145,7 @@ public async Task<IActionResult> DeleteUserAsync(string subject)
144145

145146
if (IsNullOrWhiteSpace(subject))
146147
{
147-
ModelState["subject.String"].Errors.Clear();
148+
ModelState["subject.String"]?.Errors.Clear();
148149
ModelState.AddModelError("", Messages.SubjectRequired);
149150
}
150151

@@ -167,7 +168,7 @@ public async Task<IActionResult> SetPropertyAsync(string subject, string type)
167168
{
168169
if (IsNullOrWhiteSpace(subject))
169170
{
170-
ModelState["subject.String"].Errors.Clear();
171+
ModelState["subject.String"]?.Errors.Clear();
171172
ModelState.AddModelError("", Messages.SubjectRequired);
172173
}
173174

@@ -203,7 +204,7 @@ public async Task<IActionResult> AddClaimAsync(string subject, [FromBody] ClaimV
203204

204205
if (IsNullOrWhiteSpace(subject))
205206
{
206-
ModelState["subject.String"].Errors.Clear();
207+
ModelState["subject.String"]?.Errors.Clear();
207208
ModelState.AddModelError("", Messages.SubjectRequired);
208209
}
209210

@@ -223,7 +224,7 @@ public async Task<IActionResult> AddClaimAsync(string subject, [FromBody] ClaimV
223224

224225
ModelState.AddErrors(result);
225226
}
226-
227+
227228
return BadRequest(ModelState.ToError());
228229
}
229230

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
using System.Collections.Generic;
2+
using System.Text.Json.Serialization;
3+
using IdentityManager2.Api.Models;
4+
using IdentityManager2.Core;
5+
using IdentityManager2.Core.Metadata;
6+
using Microsoft.AspNetCore.Mvc;
7+
using Microsoft.AspNetCore.Mvc.ModelBinding;
8+
9+
[JsonSerializable(typeof(PageModelParams))]
10+
partial class PageModelParams_Context : JsonSerializerContext { }
11+
12+
13+
[JsonSourceGenerationOptions(PropertyNamingPolicy = JsonKnownNamingPolicy.CamelCase)]
14+
[JsonSerializable(typeof(IEnumerable<PropertyMetadata>))]
15+
[JsonSerializable(typeof(IEnumerable<PropertyDataType>))]
16+
[JsonSerializable(typeof(PropertyDataType))]
17+
[JsonSerializable(typeof(string))]
18+
[JsonSerializable(typeof(AnonymousSubject))]
19+
[JsonSerializable(typeof(AnonymousSubjectRole))]
20+
[JsonSerializable(typeof(AnonymousUserName))]
21+
[JsonSerializable(typeof(AnonymousDetail))]
22+
[JsonSerializable(typeof(UserDetailResource))]
23+
[JsonSerializable(typeof(UserDetailDataResource))]
24+
[JsonSerializable(typeof(UserQueryResultResource))]
25+
[JsonSerializable(typeof(UserQueryResultResourceData))]
26+
[JsonSerializable(typeof(MetaResult))]
27+
public partial class MetaResult_Context : JsonSerializerContext { }
28+
29+
30+
[JsonSourceGenerationOptions(PropertyNamingPolicy = JsonKnownNamingPolicy.CamelCase)]
31+
[JsonSerializable(typeof(Dictionary<string, string>))]
32+
[JsonSerializable(typeof(UserQueryResultResource))]
33+
public partial class UserQueryResultResource_Context : JsonSerializerContext { }
34+
35+
36+
[JsonSourceGenerationOptions(PropertyNamingPolicy = JsonKnownNamingPolicy.CamelCase)]
37+
[JsonSerializable(typeof(Dictionary<string, string>))]
38+
[JsonSerializable(typeof(UserDetailDataResource))]
39+
[JsonSerializable(typeof(IEnumerable<AnonymousPropertiesDataMetaLink>))]
40+
[JsonSerializable(typeof(AnonymousUpdate))]
41+
[JsonSerializable(typeof(AnonymousClaim))]
42+
[JsonSerializable(typeof(AnonymousRolesDataMetaLink[]))]
43+
[JsonSerializable(typeof(AnonymousRolesActionLinks))]
44+
[JsonSerializable(typeof(UserDetailResource))]
45+
public partial class UserDetailResource_Context : JsonSerializerContext { }
46+
47+
48+
[JsonSourceGenerationOptions(PropertyNamingPolicy = JsonKnownNamingPolicy.CamelCase)]
49+
[JsonSerializable(typeof(Dictionary<string, string>))]
50+
[JsonSerializable(typeof(RoleQueryResultResource))]
51+
public partial class RoleQueryResultResource_Context : JsonSerializerContext { }
52+
53+
54+
[JsonSourceGenerationOptions(PropertyNamingPolicy = JsonKnownNamingPolicy.CamelCase)]
55+
[JsonSerializable(typeof(Dictionary<string, string>))]
56+
[JsonSerializable(typeof(RoleDetailResource))]
57+
public partial class RoleDetailResource_Context : JsonSerializerContext { }
58+
59+
60+
[JsonSourceGenerationOptions(PropertyNamingPolicy = JsonKnownNamingPolicy.CamelCase)]
61+
[JsonSerializable(typeof(PropertyValue[]))]
62+
public partial class ArrayPropertyValue_Context : JsonSerializerContext { }
63+
64+
65+
[JsonSourceGenerationOptions(PropertyNamingPolicy = JsonKnownNamingPolicy.CamelCase)]
66+
[JsonSerializable(typeof(ClaimValue))]
67+
public partial class ClaimValue_Context: JsonSerializerContext { }
68+
69+
70+
[JsonSourceGenerationOptions(PropertyNamingPolicy = JsonKnownNamingPolicy.CamelCase)]
71+
[JsonSerializable(typeof(AnonymousCreatedRole))]
72+
public partial class AnonymousCreatedRole_Context : JsonSerializerContext { }
73+
74+
75+
[JsonSourceGenerationOptions(PropertyNamingPolicy = JsonKnownNamingPolicy.CamelCase)]
76+
[JsonSerializable(typeof(AnonymousCreatedUser))]
77+
public partial class AnonymousCreatedUser_Context : JsonSerializerContext { }
78+
79+
[JsonSourceGenerationOptions(PropertyNamingPolicy = JsonKnownNamingPolicy.CamelCase)]
80+
[JsonSerializable(typeof(ModelStateDictionary))]
81+
public partial class ModelStateDictionary_Context : JsonSerializerContext { }
82+
83+
84+
[JsonSourceGenerationOptions(PropertyNamingPolicy = JsonKnownNamingPolicy.CamelCase)]
85+
[JsonSerializable(typeof(ErrorModel))]
86+
public partial class ErrorModel_Context : JsonSerializerContext { }
87+
88+
[JsonSourceGenerationOptions(PropertyNamingPolicy = JsonKnownNamingPolicy.CamelCase)]
89+
[JsonSerializable(typeof(List<string>))]
90+
public partial class ListStringErrors_Context : JsonSerializerContext { }
91+
92+
93+
94+
95+
[JsonSourceGenerationOptions(PropertyNamingPolicy = JsonKnownNamingPolicy.CamelCase)]
96+
[JsonSerializable(typeof(Microsoft.AspNetCore.Mvc.SerializableError))]
97+
public partial class SerializableError_Context : JsonSerializerContext { }

0 commit comments

Comments
 (0)