Skip to content

Commit

Permalink
Fixes for authorization
Browse files Browse the repository at this point in the history
* Team / My Team is again visibible for team managers
* Add missing "using League.MultiTenancy" in razor views
+ Bump version to v6.1.1
  • Loading branch information
axunonb committed May 7, 2023
1 parent 45092b5 commit 8c4e822
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 8 deletions.
2 changes: 1 addition & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<Copyright>Copyright 2011-$(CurrentYear) axuno gGmbH</Copyright>
<RepositoryUrl>https://github.com/axuno/Volleyball-League</RepositoryUrl>
<PublishRepositoryUrl>true</PublishRepositoryUrl>
<Version>6.1.0</Version>
<Version>6.1.1</Version>
<FileVersion>6.1.0</FileVersion>
<AssemblyVersion>6.0.0.0</AssemblyVersion> <!--only update AssemblyVersion with major releases -->
<LangVersion>latest</LangVersion>
Expand Down
4 changes: 2 additions & 2 deletions League/Authorization/PolicyName.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ public static class PolicyName
/// </summary>
public const string SeeTeamContactsPolicy = nameof(SeeTeamContactsPolicy);
/// <summary>
/// Policy for "my team" views
/// Policy for "my team" views, primarily for team managers and players.
/// </summary>
public const string MyTeamPolicy = nameof(MyTeamPolicy);
/// <summary>
/// Admin policy for "my team" views, so that admin can show any team as "my team"
/// </summary>
public const string MyTeamAdminPolicy = nameof(MyTeamAdminPolicy);
}
}
6 changes: 2 additions & 4 deletions League/Authorization/TeamAuthorizationHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,8 @@ public static class TeamOperations
public static readonly OperationAuthorizationRequirement ChangePhoto = new() { Name = nameof(ChangePhoto) };
public static readonly OperationAuthorizationRequirement EditTeam = new() { Name = nameof(EditTeam) };
public static readonly OperationAuthorizationRequirement AddTeamMember = new() { Name = nameof(AddTeamMember) };
public static readonly OperationAuthorizationRequirement RemoveTeamMember =
new() { Name = nameof(RemoveTeamMember) };
public static readonly OperationAuthorizationRequirement SignUpForSeason =
new() { Name = nameof(SignUpForSeason) };
public static readonly OperationAuthorizationRequirement RemoveTeamMember = new() { Name = nameof(RemoveTeamMember) };
public static readonly OperationAuthorizationRequirement SignUpForSeason = new() { Name = nameof(SignUpForSeason) };
}

public class TeamAuthorizationHandler : AuthorizationHandler<OperationAuthorizationRequirement, TeamEntity>
Expand Down
3 changes: 2 additions & 1 deletion League/Components/MainNavigationNodeBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,8 @@ protected virtual async Task CreateStandardNavigationNodes()
Key = "Teams_MyTeam",
Text = Localizer["My team"],
Url = TenantLink.Action(nameof(Team.MyTeam), nameof(Team)),
IsVisible = (await AuthorizationService.AuthorizeAsync(UserClaimsPrincipal, PolicyName.MyTeamAdminPolicy)).Succeeded
IsVisible = (await AuthorizationService.AuthorizeAsync(UserClaimsPrincipal, PolicyName.MyTeamPolicy)).Succeeded
|| (await AuthorizationService.AuthorizeAsync(UserClaimsPrincipal, PolicyName.MyTeamAdminPolicy)).Succeeded
},
new MainNavigationComponentModel.NavigationNode
{
Expand Down
1 change: 1 addition & 0 deletions League/Views/Manage/Index.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
@using League.Helpers
@using Microsoft.AspNetCore.Mvc.Localization
@using TournamentManager.MultiTenancy
@using League.MultiTenancy @* don't remove *@
@inject IViewLocalizer Localizer
@inject ITenantContext TenantContext
@inject MetaDataHelper Metadata
Expand Down
1 change: 1 addition & 0 deletions League/Views/Team/MyTeam.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
@using TournamentManager.DI
@using TournamentManager.MultiTenancy
@using TournamentManager.DAL.EntityClasses
@using League.MultiTenancy @* don't remove *@
@inject IViewLocalizer Localizer
@inject ITenantContext TenantContext
@inject TenantLink TenantLink
Expand Down

0 comments on commit 8c4e822

Please sign in to comment.