Skip to content

Commit

Permalink
Fix NRE in ViewerPageDataProvider. (#571)
Browse files Browse the repository at this point in the history
  • Loading branch information
bitbound authored Jan 20, 2023
1 parent c5a1a56 commit 97e31b4
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion Server/Services/RcImplementations/ViewerPageDataProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,19 @@ public ViewerPageDataProvider(IDataService dataService, IApplicationConfig appCo

public string GetUserDisplayName(PageModel pageModel)
{
if (string.IsNullOrWhiteSpace(pageModel?.User?.Identity?.Name))
{
return string.Empty;
}

var user = _dataService.GetUserByNameWithOrg(pageModel.User.Identity.Name);
return user.UserOptions?.DisplayName ?? user.UserName;

if (user is null)
{
return string.Empty;
}

return user.UserOptions?.DisplayName ?? user.UserName ?? string.Empty;
}

public ViewerPageTheme GetTheme(PageModel pageModel)
Expand Down

0 comments on commit 97e31b4

Please sign in to comment.