Skip to content

Commit

Permalink
Fix NRE when the user set their time zone as the site's (Lombiq Techn…
Browse files Browse the repository at this point in the history
…ologies: OCORE-200) (#16777)
  • Loading branch information
Piedone authored Sep 24, 2024
1 parent cb6b2a4 commit 9b42df2
Showing 1 changed file with 8 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
namespace OrchardCore.Users.TimeZone.Services;

/// <summary>
/// Provides the timezone defined for the currently logged-in user for the current scope (request).
/// Provides the time zone defined for the currently logged-in user for the current scope (request).
/// </summary>
public class UserTimeZoneSelector : ITimeZoneSelector
{
Expand All @@ -27,10 +27,12 @@ public async Task<TimeZoneSelectorResult> GetTimeZoneAsync()
{
var currentUser = await _userManager.GetUserAsync(_httpContextAccessor.HttpContext.User);

return new TimeZoneSelectorResult
{
Priority = 100,
TimeZoneId = async () => (await _userTimeZoneService.GetAsync(currentUser)).TimeZoneId
};
return currentUser == null
? null
: new TimeZoneSelectorResult
{
Priority = 100,
TimeZoneId = async () => (await _userTimeZoneService.GetAsync(currentUser))?.TimeZoneId
};
}
}

0 comments on commit 9b42df2

Please sign in to comment.