diff options
| author | Syndamia <kamen.d.mladenov@protonmail.com> | 2020-12-12 14:47:33 +0200 |
|---|---|---|
| committer | Syndamia <kamen.d.mladenov@protonmail.com> | 2020-12-12 14:47:33 +0200 |
| commit | 9b287f08b8e2c8d091967597bc9610afea8058ca (patch) | |
| tree | c4d24122bbe0e90774892d0b4c3a87952a988887 /API/Service | |
| parent | 688fd7d0ad87ba9a7e72266cd5f7f7f493d9cc38 (diff) | |
| download | DevHive-9b287f08b8e2c8d091967597bc9610afea8058ca.tar DevHive-9b287f08b8e2c8d091967597bc9610afea8058ca.tar.gz DevHive-9b287f08b8e2c8d091967597bc9610afea8058ca.zip | |
Improved appsettings.json reading
Diffstat (limited to 'API/Service')
| -rw-r--r-- | API/Service/UserService.cs | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/API/Service/UserService.cs b/API/Service/UserService.cs index c4f6e92..797a924 100644 --- a/API/Service/UserService.cs +++ b/API/Service/UserService.cs @@ -4,7 +4,7 @@ using AutoMapper; using Data.Models.Classes; using Data.Models.DTOs; using Microsoft.AspNetCore.Mvc; - +using Data.Models.Options; using System.IdentityModel.Tokens.Jwt; using Microsoft.IdentityModel.Tokens; using System.Security.Claims; @@ -18,13 +18,13 @@ namespace API.Service { private readonly UserDbRepository _userDbRepository; private readonly IMapper _userMapper; - private readonly IConfiguration _appSettings; + private readonly JWTOptions _jwtOptions; - public UserService(DevHiveContext context, IMapper mapper, IConfiguration appSettings) + public UserService(DevHiveContext context, IMapper mapper, JWTOptions jwtOptions) { this._userDbRepository = new UserDbRepository(context); this._userMapper = mapper; - this._appSettings = appSettings; + this._jwtOptions = jwtOptions; } public async Task<IActionResult> LoginUser(LoginDTO loginDTO) @@ -35,7 +35,7 @@ namespace API.Service return new NotFoundObjectResult("User does not exist!"); // Get key from appsettings.json - var key = Encoding.ASCII.GetBytes(_appSettings.GetSection("Secret").Value); + var key = Encoding.ASCII.GetBytes(_jwtOptions.Secret); if (user.PasswordHash != GeneratePasswordHash(loginDTO.Password)) return new BadRequestObjectResult("Incorrect password!"); |
