Skip to content

Commit b38769e

Browse files
authored
Анонимный доступ к расписанию (#2014)
* исправить проблему с анонимным доступом к расписанию * Добавить еще вариант пути к ical
1 parent 5f63227 commit b38769e

File tree

4 files changed

+14
-7
lines changed

4 files changed

+14
-7
lines changed

src/JoinRpg.Domain/JoinRpg.Domain.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
<ItemGroup>
77
<ProjectReference Include="..\JoinRpg.DataModel\JoinRpg.DataModel.csproj" />
88
<ProjectReference Include="..\JoinRpg.Helpers\JoinRpg.Helpers.csproj" />
9+
<ProjectReference Include="..\JoinRpg.Interfaces\JoinRpg.Interfaces.csproj" />
910
</ItemGroup>
1011
<ItemGroup>
1112
<PackageReference Include="JetBrains.Annotations" Version="2022.3.1" />

src/JoinRpg.Domain/ProjectEntityExtensions.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using System.Linq.Expressions;
22
using JoinRpg.DataModel;
3+
using JoinRpg.Interfaces;
34
using MustUseReturnValueAttribute = JetBrains.Annotations.MustUseReturnValueAttribute;
45
using NotNullAttribute = System.Diagnostics.CodeAnalysis.NotNullAttribute;
56
using PureAttribute = JetBrains.Annotations.PureAttribute;
@@ -29,6 +30,14 @@ public static bool HasMasterAccess([NotNull] this IProjectEntity entity, int? cu
2930
return entity.HasMasterAccess(currentUserId, acl => true);
3031
}
3132

33+
public static bool HasMasterAccess(this IProjectEntity entity, ICurrentUserAccessor currentUserAccessor)
34+
{
35+
ArgumentNullException.ThrowIfNull(entity);
36+
ArgumentNullException.ThrowIfNull(currentUserAccessor);
37+
38+
return entity.HasMasterAccess(currentUserAccessor.UserIdOrDefault, acl => true);
39+
}
40+
3241
public static T RequestMasterAccess<T>([NotNull] this T field,
3342
int? currentUserId,
3443
Expression<Func<ProjectAcl, bool>>? accessType = null)

src/JoinRpg.Portal/Controllers/Schedule/ShowScheduleController.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ public async Task<ActionResult> Index(int projectId)
5454

5555
//TODO we ignore acces rights here
5656
[HttpGet("ical")]
57+
[HttpGet("ical.ics")]
5758
public async Task<ActionResult> Ical(int projectId)
5859
{
5960
var schedule = await Manager.GetIcalSchedule();

src/JoinRpg.WebPortal.Managers/Schedule/SchedulePageManager.cs

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ private CalendarEvent BuildIcalEvent(ProgramItemPlaced evt)
8484
private void BuildAppointments(Project project, SchedulePageViewModel viewModel)
8585
{
8686
var result = new List<AppointmentViewModel>(64);
87-
var hasMasterAccess = project.HasMasterAccess(CurrentUserAccessor.UserId);
87+
var hasMasterAccess = project.HasMasterAccess(CurrentUserAccessor);
8888

8989
for (var i = 0; i < viewModel.Rows.Count; i++)
9090
{
@@ -242,15 +242,11 @@ bool HasAccess(ProjectField roomField)
242242
{
243243
return true;
244244
}
245-
if (CurrentUserAccessor.UserIdOrDefault is null)
246-
{
247-
return false;
248-
}
249-
if (project.HasMasterAccess(CurrentUserAccessor.UserId))
245+
if (project.HasMasterAccess(CurrentUserAccessor))
250246
{
251247
return true;
252248
}
253-
if (project.Claims.OfUserApproved(CurrentUserAccessor.UserId).Any())
249+
if (CurrentUserAccessor.UserIdOrDefault is int userId && project.Claims.OfUserApproved(userId).Any())
254250
{
255251
return roomField.CanPlayerView;
256252
}

0 commit comments

Comments
 (0)