Skip to content

Commit 0326610

Browse files
committed
Fix incorrect claims type
1 parent 341173d commit 0326610

File tree

22 files changed

+45
-22
lines changed

22 files changed

+45
-22
lines changed

save-points/00-get-started/BlazingPizza.Server/NotificationsController.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using System.Linq;
2+
using System.Security.Claims;
23
using System.Threading.Tasks;
34
using Microsoft.AspNetCore.Authorization;
45
using Microsoft.AspNetCore.Mvc;
@@ -36,7 +37,7 @@ public async Task<NotificationSubscription> Subscribe(NotificationSubscription s
3637

3738
private string GetUserId()
3839
{
39-
return HttpContext.User.FindFirst("http://schemas.xmlsoap.org/ws/2005/05/identity/claims/name")?.Value;
40+
return HttpContext.User.FindFirstValue(ClaimTypes.NameIdentifier);
4041
}
4142
}
4243
}

save-points/00-get-started/BlazingPizza.Server/OrdersController.cs

Lines changed: 2 additions & 1 deletion
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.Security.Claims;
45
using System.Threading.Tasks;
56
using Microsoft.AspNetCore.Mvc;
67
using Microsoft.EntityFrameworkCore;
@@ -89,7 +90,7 @@ public async Task<ActionResult<int>> PlaceOrder(Order order)
8990

9091
private string GetUserId()
9192
{
92-
return HttpContext.User.FindFirst("http://schemas.xmlsoap.org/ws/2005/05/identity/claims/name")?.Value;
93+
return HttpContext.User.FindFirstValue(ClaimTypes.NameIdentifier);
9394
}
9495

9596
private static async Task TrackAndSendNotificationsAsync(Order order, NotificationSubscription subscription)

save-points/01-Components-and-layout/BlazingPizza.Server/NotificationsController.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using System.Linq;
2+
using System.Security.Claims;
23
using System.Threading.Tasks;
34
using Microsoft.AspNetCore.Authorization;
45
using Microsoft.AspNetCore.Mvc;
@@ -36,7 +37,7 @@ public async Task<NotificationSubscription> Subscribe(NotificationSubscription s
3637

3738
private string GetUserId()
3839
{
39-
return HttpContext.User.FindFirst("http://schemas.xmlsoap.org/ws/2005/05/identity/claims/name")?.Value;
40+
return HttpContext.User.FindFirstValue(ClaimTypes.NameIdentifier);
4041
}
4142
}
4243
}

save-points/01-Components-and-layout/BlazingPizza.Server/OrdersController.cs

Lines changed: 2 additions & 1 deletion
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.Security.Claims;
45
using System.Threading.Tasks;
56
using Microsoft.AspNetCore.Mvc;
67
using Microsoft.EntityFrameworkCore;
@@ -89,7 +90,7 @@ public async Task<ActionResult<int>> PlaceOrder(Order order)
8990

9091
private string GetUserId()
9192
{
92-
return HttpContext.User.FindFirst("http://schemas.xmlsoap.org/ws/2005/05/identity/claims/name")?.Value;
93+
return HttpContext.User.FindFirstValue(ClaimTypes.NameIdentifier);
9394
}
9495

9596
private static async Task TrackAndSendNotificationsAsync(Order order, NotificationSubscription subscription)

save-points/02-customize-a-pizza/BlazingPizza.Server/NotificationsController.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using System.Linq;
2+
using System.Security.Claims;
23
using System.Threading.Tasks;
34
using Microsoft.AspNetCore.Authorization;
45
using Microsoft.AspNetCore.Mvc;
@@ -36,7 +37,7 @@ public async Task<NotificationSubscription> Subscribe(NotificationSubscription s
3637

3738
private string GetUserId()
3839
{
39-
return HttpContext.User.FindFirst("http://schemas.xmlsoap.org/ws/2005/05/identity/claims/name")?.Value;
40+
return HttpContext.User.FindFirstValue(ClaimTypes.NameIdentifier);
4041
}
4142
}
4243
}

save-points/02-customize-a-pizza/BlazingPizza.Server/OrdersController.cs

Lines changed: 2 additions & 1 deletion
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.Security.Claims;
45
using System.Threading.Tasks;
56
using Microsoft.AspNetCore.Mvc;
67
using Microsoft.EntityFrameworkCore;
@@ -89,7 +90,7 @@ public async Task<ActionResult<int>> PlaceOrder(Order order)
8990

9091
private string GetUserId()
9192
{
92-
return HttpContext.User.FindFirst("http://schemas.xmlsoap.org/ws/2005/05/identity/claims/name")?.Value;
93+
return HttpContext.User.FindFirstValue(ClaimTypes.NameIdentifier);
9394
}
9495

9596
private static async Task TrackAndSendNotificationsAsync(Order order, NotificationSubscription subscription)

save-points/03-show-order-status/BlazingPizza.Server/NotificationsController.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using System.Linq;
2+
using System.Security.Claims;
23
using System.Threading.Tasks;
34
using Microsoft.AspNetCore.Authorization;
45
using Microsoft.AspNetCore.Mvc;
@@ -36,7 +37,7 @@ public async Task<NotificationSubscription> Subscribe(NotificationSubscription s
3637

3738
private string GetUserId()
3839
{
39-
return HttpContext.User.FindFirst("http://schemas.xmlsoap.org/ws/2005/05/identity/claims/name")?.Value;
40+
return HttpContext.User.FindFirstValue(ClaimTypes.NameIdentifier);
4041
}
4142
}
4243
}

save-points/03-show-order-status/BlazingPizza.Server/OrdersController.cs

Lines changed: 2 additions & 1 deletion
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.Security.Claims;
45
using System.Threading.Tasks;
56
using Microsoft.AspNetCore.Mvc;
67
using Microsoft.EntityFrameworkCore;
@@ -89,7 +90,7 @@ public async Task<ActionResult<int>> PlaceOrder(Order order)
8990

9091
private string GetUserId()
9192
{
92-
return HttpContext.User.FindFirst("http://schemas.xmlsoap.org/ws/2005/05/identity/claims/name")?.Value;
93+
return HttpContext.User.FindFirstValue(ClaimTypes.NameIdentifier);
9394
}
9495

9596
private static async Task TrackAndSendNotificationsAsync(Order order, NotificationSubscription subscription)

save-points/04-refactor-state-management/BlazingPizza.Server/NotificationsController.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using System.Linq;
2+
using System.Security.Claims;
23
using System.Threading.Tasks;
34
using Microsoft.AspNetCore.Authorization;
45
using Microsoft.AspNetCore.Mvc;
@@ -36,7 +37,7 @@ public async Task<NotificationSubscription> Subscribe(NotificationSubscription s
3637

3738
private string GetUserId()
3839
{
39-
return HttpContext.User.FindFirst("http://schemas.xmlsoap.org/ws/2005/05/identity/claims/name")?.Value;
40+
return HttpContext.User.FindFirstValue(ClaimTypes.NameIdentifier);
4041
}
4142
}
4243
}

save-points/04-refactor-state-management/BlazingPizza.Server/OrdersController.cs

Lines changed: 2 additions & 1 deletion
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.Security.Claims;
45
using System.Threading.Tasks;
56
using Microsoft.AspNetCore.Mvc;
67
using Microsoft.EntityFrameworkCore;
@@ -89,7 +90,7 @@ public async Task<ActionResult<int>> PlaceOrder(Order order)
8990

9091
private string GetUserId()
9192
{
92-
return HttpContext.User.FindFirst("http://schemas.xmlsoap.org/ws/2005/05/identity/claims/name")?.Value;
93+
return HttpContext.User.FindFirstValue(ClaimTypes.NameIdentifier);
9394
}
9495

9596
private static async Task TrackAndSendNotificationsAsync(Order order, NotificationSubscription subscription)

0 commit comments

Comments
 (0)