File tree Expand file tree Collapse file tree 2 files changed +6
-4
lines changed Expand file tree Collapse file tree 2 files changed +6
-4
lines changed Original file line number Diff line number Diff line change 1
1
// Copyright (c) Martin Costello, 2021. All rights reserved.
2
2
// Licensed under the Apache 2.0 license. See the LICENSE file in the project root for full license information.
3
3
4
- using System . Security . Claims ;
5
4
using Microsoft . AspNetCore . Builder ;
6
5
using Microsoft . AspNetCore . Http ;
7
6
using Microsoft . AspNetCore . Routing ;
@@ -100,9 +99,6 @@ public static IEndpointRouteBuilder MapApiRoutes(this IEndpointRouteBuilder buil
100
99
private static string GetItemId ( this HttpContext context )
101
100
=> ( string ) context . GetRouteValue ( "id" ) ! ;
102
101
103
- private static string GetUserId ( this HttpContext context )
104
- => context . User . FindFirst ( ClaimTypes . NameIdentifier ) ! . Value ;
105
-
106
102
private static ITodoService GetTodoService ( this HttpContext context )
107
103
=> context . RequestServices . GetRequiredService < ITodoService > ( ) ;
108
104
}
Original file line number Diff line number Diff line change @@ -60,6 +60,12 @@ public static IServiceCollection AddGitHubAuthentication(this IServiceCollection
60
60
public static string GetProfileUrl ( this ClaimsPrincipal user )
61
61
=> user . FindFirst ( GitHubProfileClaim ) ! . Value ;
62
62
63
+ public static string GetUserId ( this HttpContext context )
64
+ => context . User . GetUserId ( ) ;
65
+
66
+ public static string GetUserId ( this ClaimsPrincipal user )
67
+ => user . FindFirst ( ClaimTypes . NameIdentifier ) ! . Value ;
68
+
63
69
public static string GetUserName ( this ClaimsPrincipal user )
64
70
=> user . FindFirst ( GitHubAuthenticationConstants . Claims . Name ) ! . Value ;
65
71
You can’t perform that action at this time.
0 commit comments