diff options
| author | transtrike <transtrike@gmail.com> | 2021-01-23 16:01:05 +0200 |
|---|---|---|
| committer | transtrike <transtrike@gmail.com> | 2021-01-23 16:01:05 +0200 |
| commit | 1f8d51c5393ea2f413de4f3e05f77d360d096ff3 (patch) | |
| tree | 529dd85dfcae02a38ff6525c75c17db49f64bd91 /src/DevHive.Services/Services | |
| parent | df06bc309d44db352441f42de7d34794a6ee54ba (diff) | |
| download | DevHive-1f8d51c5393ea2f413de4f3e05f77d360d096ff3.tar DevHive-1f8d51c5393ea2f413de4f3e05f77d360d096ff3.tar.gz DevHive-1f8d51c5393ea2f413de4f3e05f77d360d096ff3.zip | |
The beginning of role based authorization
Diffstat (limited to 'src/DevHive.Services/Services')
| -rw-r--r-- | src/DevHive.Services/Services/RoleService.cs | 3 | ||||
| -rw-r--r-- | src/DevHive.Services/Services/UserService.cs | 2 |
2 files changed, 3 insertions, 2 deletions
diff --git a/src/DevHive.Services/Services/RoleService.cs b/src/DevHive.Services/Services/RoleService.cs index 896946d..91a8c73 100644 --- a/src/DevHive.Services/Services/RoleService.cs +++ b/src/DevHive.Services/Services/RoleService.cs @@ -20,12 +20,11 @@ namespace DevHive.Services.Services this._roleMapper = mapper; } - public async Task<Guid> CreateRole(RoleServiceModel roleServiceModel) + public async Task<Guid> CreateRole(CreateRoleServiceModel roleServiceModel) { if (await this._roleRepository.DoesNameExist(roleServiceModel.Name)) throw new ArgumentException("Role already exists!"); - Role role = this._roleMapper.Map<Role>(roleServiceModel); bool success = await this._roleRepository.AddAsync(role); diff --git a/src/DevHive.Services/Services/UserService.cs b/src/DevHive.Services/Services/UserService.cs index 533f422..cf33644 100644 --- a/src/DevHive.Services/Services/UserService.cs +++ b/src/DevHive.Services/Services/UserService.cs @@ -194,6 +194,8 @@ namespace DevHive.Services.Services return false; /* Check roles */ + if(jwtRoleNames.Contains(Role.AdminRole)) + return true; // Check if jwt contains all user roles (if it doesn't, jwt is either old or tampered with) foreach (var role in user.Roles) |
