aboutsummaryrefslogtreecommitdiff
path: root/src/DevHive.Services/Services
diff options
context:
space:
mode:
authorSyndamia <kamen.d.mladenov@protonmail.com>2020-12-17 20:45:03 +0200
committerSyndamia <kamen.d.mladenov@protonmail.com>2020-12-17 20:45:03 +0200
commit19ebfbe04f07eeec3abef3530e842a10b4bb9b01 (patch)
tree8635c1e56ce40c23e493b8638e9dfd636a825fca /src/DevHive.Services/Services
parentb24b9b1ffa528f29aa87f0e48097a35386fbb8b1 (diff)
downloadDevHive-19ebfbe04f07eeec3abef3530e842a10b4bb9b01.tar
DevHive-19ebfbe04f07eeec3abef3530e842a10b4bb9b01.tar.gz
DevHive-19ebfbe04f07eeec3abef3530e842a10b4bb9b01.zip
Authorization now supports multiple tokens
Diffstat (limited to 'src/DevHive.Services/Services')
-rw-r--r--src/DevHive.Services/Services/UserService.cs12
1 files changed, 5 insertions, 7 deletions
diff --git a/src/DevHive.Services/Services/UserService.cs b/src/DevHive.Services/Services/UserService.cs
index 3e65dab..7092d61 100644
--- a/src/DevHive.Services/Services/UserService.cs
+++ b/src/DevHive.Services/Services/UserService.cs
@@ -72,12 +72,8 @@ namespace DevHive.Services.Services
User user = await this._userRepository.GetByIdAsync(id)
?? throw new ArgumentException("User does not exist!");
- //Here User has 1 role
-
UserServiceModel model = this._userMapper.Map<UserServiceModel>(user);
- //here model has 0 roles
-
return model;
}
@@ -130,10 +126,12 @@ namespace DevHive.Services.Services
{
byte[] signingKey = Encoding.ASCII.GetBytes(_jwtOptions.Secret);
- List<Claim> claims = new()
+ List<Claim> claims = new();
+
+ foreach(var role in roles)
{
- new Claim(ClaimTypes.Role, roles[0].Name) // TODO: add support for multiple roles
- };
+ claims.Add(new Claim(ClaimTypes.Role, role.Name));
+ }
SecurityTokenDescriptor tokenDescriptor = new()
{