Browse Source

Change AbpAuthorizationException as BusinessException

pull/17/head
EngincanV 6 years ago
parent
commit
415584f4cf
  1. 6
      src/EventHub.Application/Organizations/OrganizationAppService.cs
  2. 1
      src/EventHub.Domain.Shared/EventHubErrorCodes.cs
  3. 3
      src/EventHub.Domain.Shared/Localization/EventHub/en.json
  4. 14
      src/EventHub.Web/Pages/Organizations/Edit.cshtml.cs

6
src/EventHub.Application/Organizations/OrganizationAppService.cs

@ -2,10 +2,9 @@
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using EventHub.Permissions;
using Microsoft.AspNetCore.Authorization;
using Volo.Abp;
using Volo.Abp.Application.Dtos;
using Volo.Abp.Authorization;
using Volo.Abp.Domain.Repositories;
using Volo.Abp.Users;
@ -82,7 +81,8 @@ namespace EventHub.Organizations
if (organization.OwnerUserId != CurrentUser.GetId())
{
throw new AbpAuthorizationException();
throw new BusinessException(EventHubErrorCodes.NotAuthorizedToUpdateOrganizationProfile)
.WithData("OrganizationName", organization.DisplayName);
}
organization.SetDisplayName(input.DisplayName);

1
src/EventHub.Domain.Shared/EventHubErrorCodes.cs

@ -6,5 +6,6 @@
public const string NotAuthorizedToCreateEventInThisOrganization = "EventHub:NotAuthorizedToCreateEventInThisOrganization";
public const string EventEndTimeCantBeEarlierThanStartTime = "EventHub:EventEndTimeCantBeEarlierThanStartTime";
public const string CantRegisterOrUnregisterForAPastEvent = "EventHub:CantRegisterOrUnregisterForAPastEvent";
public const string NotAuthorizedToUpdateOrganizationProfile = "EventHub:NotAuthorizedToUpdateOrganizationProfile";
}
}

3
src/EventHub.Domain.Shared/Localization/EventHub/en.json

@ -46,6 +46,7 @@
"Edit": "Edit",
"EditOrganization": "Edit Organization",
"PersonalWebsite": "Personal Website",
"SocialMedia": "Social Media"
"SocialMedia": "Social Media",
"EventHub:NotAuthorizedToUpdateOrganizationProfile": "You are not authorized to update the \"{OrganizationName}\" organization."
}
}

14
src/EventHub.Web/Pages/Organizations/Edit.cshtml.cs

@ -23,19 +23,9 @@ namespace EventHub.Web.Pages.Organizations
_organizationAppService = organizationAppService;
}
public async Task<IActionResult> OnGetAsync()
public async Task OnGetAsync()
{
try
{
await GetOrganizationAsync();
}
catch (Exception exception)
{
ShowAlert(exception);
return RedirectToPage("./Index");
}
return Page();
await GetOrganizationAsync();
}
public async Task<IActionResult> OnPostAsync()

Loading…
Cancel
Save