Handle not found user profile gracefully
Changes from throwing an exception when a user profile is not found to returning null. This prevents the application from crashing when a user profile is not found, allowing for more graceful error handling.
This commit is contained in:
parent
7bf7f23925
commit
1dc37d3282
1 changed files with 1 additions and 1 deletions
|
@ -13,7 +13,7 @@ public class ApplicationUserService(ApplicationDbContext context)
|
||||||
{
|
{
|
||||||
var appUserId = identity.FindFirst(ClaimTypes.NameIdentifier)?.Value;
|
var appUserId = identity.FindFirst(ClaimTypes.NameIdentifier)?.Value;
|
||||||
var profile = await _context.UserProfiles
|
var profile = await _context.UserProfiles
|
||||||
.FirstAsync(x => x.ApplicationUserId.ToString() == appUserId)
|
.FirstOrDefaultAsync(x => x.ApplicationUserId.ToString() == appUserId)
|
||||||
?? throw new NotFoundException();
|
?? throw new NotFoundException();
|
||||||
|
|
||||||
return profile;
|
return profile;
|
||||||
|
|
Loading…
Reference in a new issue