Skip to content

Commit 8ae27e3

Browse files
committed
Resolved #83: Use AbpAuthorize attribute on app services.
1 parent b016e39 commit 8ae27e3

File tree

3 files changed

+7
-23
lines changed

3 files changed

+7
-23
lines changed

aspnet-core/src/AbpCompanyName.AbpProjectName.Application/MultiTenancy/TenantAppService.cs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
using System.Threading.Tasks;
33
using Abp.Application.Services;
44
using Abp.Application.Services.Dto;
5+
using Abp.Authorization;
56
using Abp.Domain.Repositories;
67
using Abp.Extensions;
78
using Abp.MultiTenancy;
@@ -16,6 +17,7 @@
1617

1718
namespace AbpCompanyName.AbpProjectName.MultiTenancy
1819
{
20+
[AbpAuthorize(PermissionNames.Pages_Tenants)]
1921
public class TenantAppService : AsyncCrudAppService<Tenant, TenantDto, int, PagedResultRequestDto, CreateTenantDto, TenantDto>, ITenantAppService
2022
{
2123
private readonly TenantManager _tenantManager;
@@ -43,13 +45,6 @@ IPasswordHasher<User> passwordHasher
4345
_abpZeroDbMigrator = abpZeroDbMigrator;
4446
_passwordHasher = passwordHasher;
4547
_userManager = userManager;
46-
47-
CreatePermissionName
48-
= GetAllPermissionName
49-
= GetPermissionName
50-
= UpdatePermissionName
51-
= DeletePermissionName
52-
= PermissionNames.Pages_Tenants;
5348
}
5449

5550
public override async Task<TenantDto> Create(CreateTenantDto input)

aspnet-core/src/AbpCompanyName.AbpProjectName.Application/Roles/RoleAppService.cs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
using Abp.Application.Services.Dto;
55
using Abp.Domain.Repositories;
66
using System.Linq;
7+
using Abp.Authorization;
78
using AbpCompanyName.AbpProjectName.Authorization.Roles;
89
using AbpCompanyName.AbpProjectName.Roles.Dto;
910
using Microsoft.AspNetCore.Identity;
@@ -15,6 +16,7 @@
1516

1617
namespace AbpCompanyName.AbpProjectName.Roles
1718
{
19+
[AbpAuthorize(PermissionNames.Pages_Roles)]
1820
public class RoleAppService : AsyncCrudAppService<Role, RoleDto, int, PagedResultRequestDto, CreateRoleDto, RoleDto>, IRoleAppService
1921
{
2022
private readonly RoleManager _roleManager;
@@ -25,13 +27,6 @@ public RoleAppService(IRepository<Role> repository, RoleManager roleManager, Use
2527
{
2628
_roleManager = roleManager;
2729
_userManager = userManager;
28-
29-
CreatePermissionName
30-
= GetAllPermissionName
31-
= GetPermissionName
32-
= UpdatePermissionName
33-
= DeletePermissionName
34-
= PermissionNames.Pages_Roles;
3530
}
3631

3732
public override async Task<RoleDto> Create(CreateRoleDto input)

aspnet-core/src/AbpCompanyName.AbpProjectName.Application/Users/UserAppService.cs

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,16 @@
88
using AbpCompanyName.AbpProjectName.Users.Dto;
99
using Microsoft.AspNetCore.Identity;
1010
using System.Linq;
11-
using Abp.Collections.Extensions;
11+
using Abp.Authorization;
1212
using Microsoft.EntityFrameworkCore;
1313
using Abp.IdentityFramework;
1414
using AbpCompanyName.AbpProjectName.Authorization.Roles;
1515
using AbpCompanyName.AbpProjectName.Roles.Dto;
1616

1717
namespace AbpCompanyName.AbpProjectName.Users
1818
{
19-
public class UserAppService : AsyncCrudAppService<User, UserDto, long, PagedResultRequestDto, CreateUserDto, UserDto>, IUserAppService
19+
[AbpAuthorize(PermissionNames.Pages_Users)]
20+
public class UserAppService : AsyncCrudAppService<User, UserDto, long, PagedResultRequestDto, CreateUserDto, UserDto>, IUserAppService
2021
{
2122
private readonly UserManager _userManager;
2223
private readonly IPasswordHasher<User> _passwordHasher;
@@ -28,13 +29,6 @@ public UserAppService(IRepository<User, long> repository, UserManager userManage
2829
_userManager = userManager;
2930
_passwordHasher = passwordHasher;
3031
_roleRepository = roleRepository;
31-
32-
CreatePermissionName
33-
= GetAllPermissionName
34-
= GetPermissionName
35-
= UpdatePermissionName
36-
= DeletePermissionName
37-
= PermissionNames.Pages_Users;
3832
}
3933

4034
public override async Task<UserDto> Create(CreateUserDto input)

0 commit comments

Comments
 (0)