Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove unnecessary null check in 2FA authorization filter #17009

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ protected override string SettingsGroupId

public override async Task<IDisplayResult> EditAsync(ISite site, AdminSettings settings, BuildEditorContext context)
{
var user = _httpContextAccessor.HttpContext?.User;
var user = _httpContextAccessor.HttpContext.User;
hishamco marked this conversation as resolved.
Show resolved Hide resolved

if (!await _authorizationService.AuthorizeAsync(user, PermissionsAdminSettings.ManageAdminSettings))
{
Expand All @@ -48,7 +48,7 @@ public override async Task<IDisplayResult> EditAsync(ISite site, AdminSettings s

public override async Task<IDisplayResult> UpdateAsync(ISite site, AdminSettings settings, UpdateEditorContext context)
{
var user = _httpContextAccessor.HttpContext?.User;
var user = _httpContextAccessor.HttpContext.User;
hishamco marked this conversation as resolved.
Show resolved Hide resolved

if (!await _authorizationService.AuthorizeAsync(user, PermissionsAdminSettings.ManageAdminSettings))
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public async ValueTask BuildNavigationAsync(string name, NavigationBuilder build
foreach (var tree in trees)
{
if (await _authorizationService.AuthorizeAsync(
_httpContextAccessor.HttpContext?.User,
_httpContextAccessor.HttpContext.User,
hishamco marked this conversation as resolved.
Show resolved Hide resolved
Permissions.CreatePermissionForAdminMenu(tree.Name)))
{
await BuildTreeAsync(tree, builder);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public override async Task<IDisplayResult> UpdateAsync(ArchiveLaterPart part, Up
{
var httpContext = _httpContextAccessor.HttpContext;

if (await _authorizationService.AuthorizeAsync(httpContext?.User, CommonPermissions.PublishContent, part.ContentItem))
if (await _authorizationService.AuthorizeAsync(httpContext.User, CommonPermissions.PublishContent, part.ContentItem))
hishamco marked this conversation as resolved.
Show resolved Hide resolved
{
var viewModel = new ArchiveLaterPartViewModel();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ protected override string SettingsGroupId

public override async Task<IDisplayResult> EditAsync(ISite site, AuditTrailSettings settings, BuildEditorContext context)
{
if (!await _authorizationService.AuthorizeAsync(_httpContextAccessor.HttpContext?.User, AuditTrailPermissions.ManageAuditTrailSettings))
if (!await _authorizationService.AuthorizeAsync(_httpContextAccessor.HttpContext.User, AuditTrailPermissions.ManageAuditTrailSettings))
hishamco marked this conversation as resolved.
Show resolved Hide resolved
{
return null;
}
Expand Down Expand Up @@ -81,7 +81,7 @@ public override async Task<IDisplayResult> EditAsync(ISite site, AuditTrailSetti

public override async Task<IDisplayResult> UpdateAsync(ISite site, AuditTrailSettings settings, UpdateEditorContext context)
{
if (!await _authorizationService.AuthorizeAsync(_httpContextAccessor.HttpContext?.User, AuditTrailPermissions.ManageAuditTrailSettings))
if (!await _authorizationService.AuthorizeAsync(_httpContextAccessor.HttpContext.User, AuditTrailPermissions.ManageAuditTrailSettings))
hishamco marked this conversation as resolved.
Show resolved Hide resolved
{
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ protected override string SettingsGroupId

public override async Task<IDisplayResult> EditAsync(ISite site, AuditTrailTrimmingSettings section, BuildEditorContext context)
{
var user = _httpContextAccessor.HttpContext?.User;
var user = _httpContextAccessor.HttpContext.User;
hishamco marked this conversation as resolved.
Show resolved Hide resolved
if (!await _authorizationService.AuthorizeAsync(user, AuditTrailPermissions.ManageAuditTrailSettings))
{
return null;
Expand All @@ -42,7 +42,7 @@ public override async Task<IDisplayResult> EditAsync(ISite site, AuditTrailTrimm

public override async Task<IDisplayResult> UpdateAsync(ISite site, AuditTrailTrimmingSettings section, UpdateEditorContext context)
{
var user = _httpContextAccessor.HttpContext?.User;
var user = _httpContextAccessor.HttpContext.User;
hishamco marked this conversation as resolved.
Show resolved Hide resolved
if (!await _authorizationService.AuthorizeAsync(user, AuditTrailPermissions.ManageAuditTrailSettings))
{
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public async Task<IActionResult> SearchContentItems(string part, string field, s
.GetAsync(results.Select(r => r.ContentItemId));

var selectedItems = new List<VueMultiselectItemViewModel>();
var user = _httpContextAccessor.HttpContext?.User;
var user = _httpContextAccessor.HttpContext.User;
hishamco marked this conversation as resolved.
Show resolved Hide resolved
foreach (var contentItem in contentItems)
{
selectedItems.Add(new VueMultiselectItemViewModel()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ protected override string SettingsGroupId

public override async Task<IDisplayResult> EditAsync(ISite site, ContentCulturePickerSettings settings, BuildEditorContext context)
{
var user = _httpContextAccessor.HttpContext?.User;
var user = _httpContextAccessor.HttpContext.User;
hishamco marked this conversation as resolved.
Show resolved Hide resolved

if (!await _authorizationService.AuthorizeAsync(user, Permissions.ManageContentCulturePicker))
{
Expand All @@ -45,7 +45,7 @@ public override async Task<IDisplayResult> EditAsync(ISite site, ContentCultureP

public override async Task<IDisplayResult> UpdateAsync(ISite site, ContentCulturePickerSettings section, UpdateEditorContext context)
{
var user = _httpContextAccessor.HttpContext?.User;
var user = _httpContextAccessor.HttpContext.User;
hishamco marked this conversation as resolved.
Show resolved Hide resolved

if (!await _authorizationService.AuthorizeAsync(user, Permissions.ManageContentCulturePicker))
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ protected override string SettingsGroupId

public override async Task<IDisplayResult> EditAsync(ISite site, ContentRequestCultureProviderSettings settings, BuildEditorContext context)
{
var user = _httpContextAccessor.HttpContext?.User;
var user = _httpContextAccessor.HttpContext.User;
hishamco marked this conversation as resolved.
Show resolved Hide resolved

if (!await _authorizationService.AuthorizeAsync(user, Permissions.ManageContentCulturePicker))
{
Expand All @@ -44,7 +44,7 @@ public override async Task<IDisplayResult> EditAsync(ISite site, ContentRequestC

public override async Task<IDisplayResult> UpdateAsync(ISite site, ContentRequestCultureProviderSettings settings, UpdateEditorContext context)
{
var user = _httpContextAccessor.HttpContext?.User;
var user = _httpContextAccessor.HttpContext.User;
hishamco marked this conversation as resolved.
Show resolved Hide resolved

if (!await _authorizationService.AuthorizeAsync(user, Permissions.ManageContentCulturePicker))
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public override Task<IDisplayResult> DisplayAsync(ContentItem contentItem, Build
return Task.FromResult<IDisplayResult>(
Initialize<ContentItemViewModel>("AuditTrailContentsAction_SummaryAdmin", m => m.ContentItem = contentItem)
.Location("SummaryAdmin", "ActionsMenu:10")
.RenderWhen(() => _authorizationService.AuthorizeAsync(_httpContextAccessor.HttpContext?.User, AuditTrailPermissions.ViewAuditTrail))
.RenderWhen(() => _authorizationService.AuthorizeAsync(_httpContextAccessor.HttpContext.User, AuditTrailPermissions.ViewAuditTrail))
hishamco marked this conversation as resolved.
Show resolved Hide resolved
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ protected override string SettingsGroupId

public override async Task<IDisplayResult> EditAsync(ISite site, ContentAuditTrailSettings section, BuildEditorContext context)
{
var user = _httpContextAccessor.HttpContext?.User;
var user = _httpContextAccessor.HttpContext.User;
hishamco marked this conversation as resolved.
Show resolved Hide resolved
if (!await _authorizationService.AuthorizeAsync(user, AuditTrailPermissions.ManageAuditTrailSettings))
{
return null;
Expand All @@ -44,7 +44,7 @@ public override async Task<IDisplayResult> EditAsync(ISite site, ContentAuditTra

public override async Task<IDisplayResult> UpdateAsync(ISite site, ContentAuditTrailSettings section, UpdateEditorContext context)
{
var user = _httpContextAccessor.HttpContext?.User;
var user = _httpContextAccessor.HttpContext.User;
hishamco marked this conversation as resolved.
Show resolved Hide resolved
if (!await _authorizationService.AuthorizeAsync(user, AuditTrailPermissions.ManageAuditTrailSettings))
{
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ protected override string SettingsGroupId

public override async Task<IDisplayResult> EditAsync(ISite site, ExportContentToDeploymentTargetSettings settings, BuildEditorContext context)
{
var user = _httpContextAccessor.HttpContext?.User;
var user = _httpContextAccessor.HttpContext.User;
hishamco marked this conversation as resolved.
Show resolved Hide resolved
if (!await _authorizationService.AuthorizeAsync(user, OrchardCore.Deployment.CommonPermissions.ManageDeploymentPlan))
{
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public OwnerEditorDriver(IAuthorizationService authorizationService,

public override async Task<IDisplayResult> EditAsync(CommonPart part, BuildPartEditorContext context)
{
var currentUser = _httpContextAccessor.HttpContext?.User;
var currentUser = _httpContextAccessor.HttpContext.User;
hishamco marked this conversation as resolved.
Show resolved Hide resolved

if (!await _authorizationService.AuthorizeAsync(currentUser, CommonPermissions.EditContentOwner, part.ContentItem))
{
Expand Down Expand Up @@ -61,7 +61,7 @@ public override async Task<IDisplayResult> EditAsync(CommonPart part, BuildPartE

public override async Task<IDisplayResult> UpdateAsync(CommonPart part, UpdatePartEditorContext context)
{
var currentUser = _httpContextAccessor.HttpContext?.User;
var currentUser = _httpContextAccessor.HttpContext.User;
hishamco marked this conversation as resolved.
Show resolved Hide resolved

if (!await _authorizationService.AuthorizeAsync(currentUser, CommonPermissions.EditContentOwner, part.ContentItem))
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public async Task<ContentTypeDefinition> GetSettingsTypeAsync(string settingsTyp

public Task<bool> CanUserCreateSettingsAsync(ContentTypeDefinition settingsType)
{
var user = _httpContextAccessor.HttpContext?.User;
var user = _httpContextAccessor.HttpContext.User;
hishamco marked this conversation as resolved.
Show resolved Hide resolved

return _authorizationService.AuthorizeAsync(user, Permissions.CreatePermissionForType(settingsType));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ protected override string SettingsGroupId

public override async Task<IDisplayResult> EditAsync(ISite site, AzureEmailSettings settings, BuildEditorContext context)
{
if (!await _authorizationService.AuthorizeAsync(_httpContextAccessor.HttpContext?.User, Permissions.ManageEmailSettings))
if (!await _authorizationService.AuthorizeAsync(_httpContextAccessor.HttpContext.User, Permissions.ManageEmailSettings))
hishamco marked this conversation as resolved.
Show resolved Hide resolved
{
return null;
}
Expand All @@ -66,7 +66,7 @@ public override async Task<IDisplayResult> EditAsync(ISite site, AzureEmailSetti

public override async Task<IDisplayResult> UpdateAsync(ISite site, AzureEmailSettings settings, UpdateEditorContext context)
{
if (!await _authorizationService.AuthorizeAsync(_httpContextAccessor.HttpContext?.User, Permissions.ManageEmailSettings))
if (!await _authorizationService.AuthorizeAsync(_httpContextAccessor.HttpContext.User, Permissions.ManageEmailSettings))
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (!await _authorizationService.AuthorizeAsync(_httpContextAccessor.HttpContext.User, Permissions.ManageEmailSettings))
if (!await _authorizationService.AuthorizeAsync(_httpContextAccessor.HttpContext?.User, Permissions.ManageEmailSettings))

{
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public SmtpSettingsDisplayDriver(

public override async Task<IDisplayResult> EditAsync(ISite site, SmtpSettings settings, BuildEditorContext context)
{
if (!await _authorizationService.AuthorizeAsync(_httpContextAccessor.HttpContext?.User, Permissions.ManageEmailSettings))
if (!await _authorizationService.AuthorizeAsync(_httpContextAccessor.HttpContext.User, Permissions.ManageEmailSettings))
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (!await _authorizationService.AuthorizeAsync(_httpContextAccessor.HttpContext.User, Permissions.ManageEmailSettings))
if (!await _authorizationService.AuthorizeAsync(_httpContextAccessor.HttpContext?.User, Permissions.ManageEmailSettings))

{
return null;
}
Expand Down Expand Up @@ -83,7 +83,7 @@ public override async Task<IDisplayResult> EditAsync(ISite site, SmtpSettings se

public override async Task<IDisplayResult> UpdateAsync(ISite site, SmtpSettings settings, UpdateEditorContext context)
{
if (!await _authorizationService.AuthorizeAsync(_httpContextAccessor.HttpContext?.User, Permissions.ManageEmailSettings))
if (!await _authorizationService.AuthorizeAsync(_httpContextAccessor.HttpContext.User, Permissions.ManageEmailSettings))
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (!await _authorizationService.AuthorizeAsync(_httpContextAccessor.HttpContext.User, Permissions.ManageEmailSettings))
if (!await _authorizationService.AuthorizeAsync(_httpContextAccessor.HttpContext?.User, Permissions.ManageEmailSettings))

{
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public EmailSettingsDisplayDriver(
}
public override async Task<IDisplayResult> EditAsync(ISite site, EmailSettings settings, BuildEditorContext context)
{
if (!await _authorizationService.AuthorizeAsync(_httpContextAccessor.HttpContext?.User, Permissions.ManageEmailSettings))
if (!await _authorizationService.AuthorizeAsync(_httpContextAccessor.HttpContext.User, Permissions.ManageEmailSettings))
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (!await _authorizationService.AuthorizeAsync(_httpContextAccessor.HttpContext.User, Permissions.ManageEmailSettings))
if (!await _authorizationService.AuthorizeAsync(_httpContextAccessor.HttpContext?.User, Permissions.ManageEmailSettings))

{
return null;
}
Expand All @@ -64,7 +64,7 @@ public override async Task<IDisplayResult> EditAsync(ISite site, EmailSettings s

public override async Task<IDisplayResult> UpdateAsync(ISite site, EmailSettings settings, UpdateEditorContext context)
{
if (!await _authorizationService.AuthorizeAsync(_httpContextAccessor.HttpContext?.User, Permissions.ManageEmailSettings))
if (!await _authorizationService.AuthorizeAsync(_httpContextAccessor.HttpContext.User, Permissions.ManageEmailSettings))
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (!await _authorizationService.AuthorizeAsync(_httpContextAccessor.HttpContext.User, Permissions.ManageEmailSettings))
if (!await _authorizationService.AuthorizeAsync(_httpContextAccessor.HttpContext?.User, Permissions.ManageEmailSettings))

{
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ protected override string SettingsGroupId

public override async Task<IDisplayResult> EditAsync(ISite site, FacebookPixelSettings settings, BuildEditorContext context)
{
var user = _httpContextAccessor.HttpContext?.User;
var user = _httpContextAccessor.HttpContext.User;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
var user = _httpContextAccessor.HttpContext.User;
var user = _httpContextAccessor.HttpContext?.User;

if (!await _authorizationService.AuthorizeAsync(user, Permissions.ManageFacebookApp))
{
return null;
Expand All @@ -42,7 +42,7 @@ public override async Task<IDisplayResult> EditAsync(ISite site, FacebookPixelSe

public override async Task<IDisplayResult> UpdateAsync(ISite site, FacebookPixelSettings settings, UpdateEditorContext context)
{
if (!await _authorizationService.AuthorizeAsync(_httpContextAccessor.HttpContext?.User, Permissions.ManageFacebookApp))
if (!await _authorizationService.AuthorizeAsync(_httpContextAccessor.HttpContext.User, Permissions.ManageFacebookApp))
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (!await _authorizationService.AuthorizeAsync(_httpContextAccessor.HttpContext.User, Permissions.ManageFacebookApp))
if (!await _authorizationService.AuthorizeAsync(_httpContextAccessor.HttpContext?.User, Permissions.ManageFacebookApp))

{
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ protected override string SettingsGroupId

public override async Task<IDisplayResult> EditAsync(ISite site, FacebookSettings settings, BuildEditorContext context)
{
var user = _httpContextAccessor.HttpContext?.User;
var user = _httpContextAccessor.HttpContext.User;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
var user = _httpContextAccessor.HttpContext.User;
var user = _httpContextAccessor.HttpContext?.User;

if (!await _authorizationService.AuthorizeAsync(user, Permissions.ManageFacebookApp))
{
return null;
Expand Down Expand Up @@ -75,7 +75,7 @@ public override async Task<IDisplayResult> EditAsync(ISite site, FacebookSetting

public override async Task<IDisplayResult> UpdateAsync(ISite site, FacebookSettings settings, UpdateEditorContext context)
{
var user = _httpContextAccessor.HttpContext?.User;
var user = _httpContextAccessor.HttpContext.User;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
var user = _httpContextAccessor.HttpContext.User;
var user = _httpContextAccessor.HttpContext?.User;


if (!await _authorizationService.AuthorizeAsync(user, Permissions.ManageFacebookApp))
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ protected override string SettingsGroupId

public override async Task<IDisplayResult> EditAsync(ISite site, FacebookLoginSettings settings, BuildEditorContext context)
{
var user = _httpContextAccessor.HttpContext?.User;
var user = _httpContextAccessor.HttpContext.User;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
var user = _httpContextAccessor.HttpContext.User;
var user = _httpContextAccessor.HttpContext?.User;

if (!await _authorizationService.AuthorizeAsync(user, Permissions.ManageFacebookApp))
{
return null;
Expand All @@ -46,7 +46,7 @@ public override async Task<IDisplayResult> EditAsync(ISite site, FacebookLoginSe

public override async Task<IDisplayResult> UpdateAsync(ISite site, FacebookLoginSettings settings, UpdateEditorContext context)
{
var user = _httpContextAccessor.HttpContext?.User;
var user = _httpContextAccessor.HttpContext.User;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
var user = _httpContextAccessor.HttpContext.User;
var user = _httpContextAccessor.HttpContext?.User;

if (!await _authorizationService.AuthorizeAsync(user, Permissions.ManageFacebookApp))
{
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ protected override string SettingsGroupId

public override async Task<IDisplayResult> EditAsync(ISite site, GitHubAuthenticationSettings settings, BuildEditorContext context)
{
var user = _httpContextAccessor.HttpContext?.User;
var user = _httpContextAccessor.HttpContext.User;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
var user = _httpContextAccessor.HttpContext.User;
var user = _httpContextAccessor.HttpContext?.User;

if (!await _authorizationService.AuthorizeAsync(user, Permissions.ManageGitHubAuthentication))
{
return null;
Expand Down Expand Up @@ -78,7 +78,7 @@ public override async Task<IDisplayResult> EditAsync(ISite site, GitHubAuthentic

public override async Task<IDisplayResult> UpdateAsync(ISite site, GitHubAuthenticationSettings settings, UpdateEditorContext context)
{
var user = _httpContextAccessor.HttpContext?.User;
var user = _httpContextAccessor.HttpContext.User;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
var user = _httpContextAccessor.HttpContext.User;
var user = _httpContextAccessor.HttpContext?.User;

if (!await _authorizationService.AuthorizeAsync(user, Permissions.ManageGitHubAuthentication))
{
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public GoogleAnalyticsSettingsDisplayDriver(

public override async Task<IDisplayResult> EditAsync(ISite site, GoogleAnalyticsSettings settings, BuildEditorContext context)
{
var user = _httpContextAccessor.HttpContext?.User;
var user = _httpContextAccessor.HttpContext.User;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
var user = _httpContextAccessor.HttpContext.User;
var user = _httpContextAccessor.HttpContext?.User;

if (!await _authorizationService.AuthorizeAsync(user, Permissions.ManageGoogleAnalytics))
{
return null;
Expand All @@ -42,7 +42,7 @@ public override async Task<IDisplayResult> EditAsync(ISite site, GoogleAnalytics

public override async Task<IDisplayResult> UpdateAsync(ISite site, GoogleAnalyticsSettings settings, UpdateEditorContext context)
{
var user = _httpContextAccessor.HttpContext?.User;
var user = _httpContextAccessor.HttpContext.User;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
var user = _httpContextAccessor.HttpContext.User;
var user = _httpContextAccessor.HttpContext?.User;

if (!await _authorizationService.AuthorizeAsync(user, Permissions.ManageGoogleAnalytics))
{
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ protected override string SettingsGroupId

public override async Task<IDisplayResult> EditAsync(ISite site, GoogleAuthenticationSettings settings, BuildEditorContext context)
{
var user = _httpContextAccessor.HttpContext?.User;
var user = _httpContextAccessor.HttpContext.User;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
var user = _httpContextAccessor.HttpContext.User;
var user = _httpContextAccessor.HttpContext?.User;

if (!await _authorizationService.AuthorizeAsync(user, Permissions.ManageGoogleAuthentication))
{
return null;
Expand Down Expand Up @@ -78,7 +78,7 @@ public override async Task<IDisplayResult> EditAsync(ISite site, GoogleAuthentic

public override async Task<IDisplayResult> UpdateAsync(ISite site, GoogleAuthenticationSettings settings, UpdateEditorContext context)
{
var user = _httpContextAccessor.HttpContext?.User;
var user = _httpContextAccessor.HttpContext.User;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
var user = _httpContextAccessor.HttpContext.User;
var user = _httpContextAccessor.HttpContext?.User;

if (!await _authorizationService.AuthorizeAsync(user, Permissions.ManageGoogleAuthentication))
{
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ protected override string SettingsGroupId

public override async Task<IDisplayResult> EditAsync(ISite site, GoogleTagManagerSettings settings, BuildEditorContext context)
{
var user = _httpContextAccessor.HttpContext?.User;
var user = _httpContextAccessor.HttpContext.User;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
var user = _httpContextAccessor.HttpContext.User;
var user = _httpContextAccessor.HttpContext?.User;

if (!await _authorizationService.AuthorizeAsync(user, Permissions.ManageGoogleTagManager))
{
return null;
Expand All @@ -42,7 +42,7 @@ public override async Task<IDisplayResult> EditAsync(ISite site, GoogleTagManage

public override async Task<IDisplayResult> UpdateAsync(ISite site, GoogleTagManagerSettings settings, UpdateEditorContext context)
{
var user = _httpContextAccessor.HttpContext?.User;
var user = _httpContextAccessor.HttpContext.User;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
var user = _httpContextAccessor.HttpContext.User;
var user = _httpContextAccessor.HttpContext?.User;

if (!await _authorizationService.AuthorizeAsync(user, Permissions.ManageGoogleTagManager))
{
return null;
Expand Down
Loading