aboutsummaryrefslogtreecommitdiff
path: root/API/Service
diff options
context:
space:
mode:
authorSyndamia <kamen.d.mladenov@protonmail.com>2020-12-11 21:48:49 +0200
committerSyndamia <kamen.d.mladenov@protonmail.com>2020-12-11 21:49:05 +0200
commitd8f253c6710cb23c632d3fc8a31d4d7d1ee0b9ff (patch)
tree5c7d3f970a6ba549bb30160397ae9b7f544a8a71 /API/Service
parentc63b86e74230144c111a380b272a0260e6ed019b (diff)
downloadDevHive-d8f253c6710cb23c632d3fc8a31d4d7d1ee0b9ff.tar
DevHive-d8f253c6710cb23c632d3fc8a31d4d7d1ee0b9ff.tar.gz
DevHive-d8f253c6710cb23c632d3fc8a31d4d7d1ee0b9ff.zip
Authorization key is gotten from appsettings.json (AppSettings/Secret)
Diffstat (limited to 'API/Service')
-rw-r--r--API/Service/UserService.cs9
1 files changed, 5 insertions, 4 deletions
diff --git a/API/Service/UserService.cs b/API/Service/UserService.cs
index b715f8c..4ace934 100644
--- a/API/Service/UserService.cs
+++ b/API/Service/UserService.cs
@@ -10,6 +10,7 @@ using Microsoft.IdentityModel.Tokens;
using System.Security.Claims;
using System;
using System.Text;
+using Microsoft.Extensions.Configuration;
namespace API.Service
{
@@ -17,11 +18,13 @@ namespace API.Service
{
private readonly UserDbRepository _userDbRepository;
private readonly IMapper _userMapper;
+ private readonly IConfiguration _appSettings;
- public UserService(DevHiveContext context, IMapper mapper)
+ public UserService(DevHiveContext context, IMapper mapper, IConfiguration appSettings)
{
this._userDbRepository = new UserDbRepository(context);
this._userMapper = mapper;
+ this._appSettings = appSettings;
}
public async Task<IActionResult> LoginUser(UserDTO userDTO)
@@ -31,9 +34,7 @@ namespace API.Service
if (user == null)
return new NotFoundObjectResult("User does not exist!");
-
- // Temporary, TODO: get key from appsettings
- var key = Encoding.ASCII.GetBytes(")H@McQfTB?E(H+Mb8x/A?D(Gr4u7x!A%WnZr4t7weThWmZq4KbPeShVm*G-KaPdSz%C*F-Ja6w9z$C&F");
+ var key = Encoding.ASCII.GetBytes(_appSettings.GetSection("Secret").Value);
var tokenHandler = new JwtSecurityTokenHandler();
var tokenDescriptor = new SecurityTokenDescriptor