Skip to content

Commit adbd741

Browse files
authored
Add more MapIdentityApi endpoints (#49498)
1 parent 7a46594 commit adbd741

34 files changed

+1819
-225
lines changed

src/Http/Routing/src/EndpointNameMetadata.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// Licensed to the .NET Foundation under one or more agreements.
22
// The .NET Foundation licenses this file to you under the MIT license.
33

4+
using System.Diagnostics;
45
using Microsoft.AspNetCore.Http;
56
using Microsoft.AspNetCore.Shared;
67

@@ -13,6 +14,7 @@ namespace Microsoft.AspNetCore.Routing;
1314
/// Endpoint names must be unique within an application, and can be used to unambiguously
1415
/// identify a desired endpoint for URI generation using <see cref="LinkGenerator"/>.
1516
/// </remarks>
17+
[DebuggerDisplay("{ToString(),nq}")]
1618
public class EndpointNameMetadata : IEndpointNameMetadata
1719
{
1820
/// <summary>
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the MIT license.
3+
4+
namespace Microsoft.AspNetCore.Identity.DTO;
5+
6+
internal sealed class TwoFactorResponse
7+
{
8+
public required string SharedKey { get; init; }
9+
public required int RecoveryCodesLeft { get; init; }
10+
public string[]? RecoveryCodes { get; init; }
11+
public required bool IsTwoFactorEnabled { get; init; }
12+
public required bool IsMachineRemembered { get; init; }
13+
}

src/Identity/Core/src/DTO/IdentityEndpointsJsonSerializerContext.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,13 @@ namespace Microsoft.AspNetCore.Identity.DTO;
77

88
[JsonSerializable(typeof(RegisterRequest))]
99
[JsonSerializable(typeof(LoginRequest))]
10+
[JsonSerializable(typeof(RefreshRequest))]
11+
[JsonSerializable(typeof(ResetPasswordRequest))]
12+
[JsonSerializable(typeof(ResendEmailRequest))]
13+
[JsonSerializable(typeof(InfoRequest))]
14+
[JsonSerializable(typeof(InfoResponse))]
15+
[JsonSerializable(typeof(TwoFactorRequest))]
16+
[JsonSerializable(typeof(TwoFactorResponse))]
1017
internal sealed partial class IdentityEndpointsJsonSerializerContext : JsonSerializerContext
1118
{
1219
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the MIT license.
3+
4+
namespace Microsoft.AspNetCore.Identity.DTO;
5+
6+
internal sealed class InfoRequest
7+
{
8+
public string? NewUsername { get; init; }
9+
public string? NewEmail { get; init; }
10+
public string? NewPassword { get; init; }
11+
public string? OldPassword { get; init; }
12+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the MIT license.
3+
4+
namespace Microsoft.AspNetCore.Identity.DTO;
5+
6+
internal sealed class InfoResponse
7+
{
8+
public required string Username { get; init; }
9+
public required string Email { get; init; }
10+
public required IDictionary<string, string> Claims { get; init; }
11+
}

src/Identity/Core/src/DTO/LoginRequest.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,6 @@ internal sealed class LoginRequest
77
{
88
public required string Username { get; init; }
99
public required string Password { get; init; }
10+
public string? TwoFactorCode { get; init; }
11+
public string? TwoFactorRecoveryCode { get; init; }
1012
}

src/Identity/Core/src/DTO/RegisterRequest.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,5 @@ internal sealed class RegisterRequest
77
{
88
public required string Username { get; init; }
99
public required string Password { get; init; }
10+
public required string Email { get; init; }
1011
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the MIT license.
3+
4+
namespace Microsoft.AspNetCore.Identity.DTO;
5+
6+
internal sealed class ResendEmailRequest
7+
{
8+
public required string Email { get; init; }
9+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the MIT license.
3+
4+
namespace Microsoft.AspNetCore.Identity.DTO;
5+
6+
internal sealed class ResetPasswordRequest
7+
{
8+
public required string Email { get; init; }
9+
public string? ResetCode { get; init; }
10+
public string? NewPassword { get; init; }
11+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the MIT license.
3+
4+
namespace Microsoft.AspNetCore.Identity.DTO;
5+
6+
internal sealed class TwoFactorRequest
7+
{
8+
public bool? Enable { get; init; }
9+
public string? TwoFactorCode { get; init; }
10+
11+
public bool ResetSharedKey { get; init; }
12+
public bool ResetRecoveryCodes { get; init; }
13+
public bool ForgetMachine { get; init; }
14+
}

0 commit comments

Comments
 (0)