Add pinCode to TokenDTO
This commit is contained in:
parent
eb0263dee8
commit
0b0b54c6af
@ -11,5 +11,6 @@ namespace Manager.Interfaces.DTO
|
|||||||
public int expires_in { get; set; }
|
public int expires_in { get; set; }
|
||||||
public DateTimeOffset expiration { get; set; }
|
public DateTimeOffset expiration { get; set; }
|
||||||
public string instanceId { get; set; }
|
public string instanceId { get; set; }
|
||||||
|
public int? pinCode { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -13,6 +13,7 @@ using Microsoft.IdentityModel.Tokens;
|
|||||||
using Manager.Framework.Business;
|
using Manager.Framework.Business;
|
||||||
using Manager.Interfaces.DTO;
|
using Manager.Interfaces.DTO;
|
||||||
using System.IdentityModel.Tokens.Jwt;
|
using System.IdentityModel.Tokens.Jwt;
|
||||||
|
using Manager.Services;
|
||||||
|
|
||||||
namespace ManagerService.Service.Services
|
namespace ManagerService.Service.Services
|
||||||
{
|
{
|
||||||
@ -24,6 +25,7 @@ namespace ManagerService.Service.Services
|
|||||||
private readonly ILogger<TokensService> _logger;
|
private readonly ILogger<TokensService> _logger;
|
||||||
private readonly TokensSettings _tokenSettings;
|
private readonly TokensSettings _tokenSettings;
|
||||||
private readonly ProfileLogic _profileLogic;
|
private readonly ProfileLogic _profileLogic;
|
||||||
|
private InstanceDatabaseService _instanceService;
|
||||||
|
|
||||||
private readonly SigningCredentials _signingCredentials;
|
private readonly SigningCredentials _signingCredentials;
|
||||||
|
|
||||||
@ -35,11 +37,12 @@ namespace ManagerService.Service.Services
|
|||||||
/// <param name="context">Database context</param>
|
/// <param name="context">Database context</param>
|
||||||
/// <param name="profileLogic">Profile logic</param>
|
/// <param name="profileLogic">Profile logic</param>
|
||||||
/// <param name="emailClient">Email client</param>
|
/// <param name="emailClient">Email client</param>
|
||||||
public TokensService(ILogger<TokensService> logger, IOptions<TokensSettings> tokenSettings, ProfileLogic profileLogic)
|
public TokensService(ILogger<TokensService> logger, IOptions<TokensSettings> tokenSettings, ProfileLogic profileLogic, InstanceDatabaseService instanceService)
|
||||||
{
|
{
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
_tokenSettings = tokenSettings.Value;
|
_tokenSettings = tokenSettings.Value;
|
||||||
_profileLogic = profileLogic;
|
_profileLogic = profileLogic;
|
||||||
|
_instanceService = instanceService;
|
||||||
|
|
||||||
var key = Encoding.UTF8.GetBytes(_tokenSettings.Secret);
|
var key = Encoding.UTF8.GetBytes(_tokenSettings.Secret);
|
||||||
_signingCredentials = new SigningCredentials(new SymmetricSecurityKey(key), SecurityAlgorithms.HmacSha256Signature);
|
_signingCredentials = new SigningCredentials(new SymmetricSecurityKey(key), SecurityAlgorithms.HmacSha256Signature);
|
||||||
@ -73,6 +76,8 @@ namespace ManagerService.Service.Services
|
|||||||
};
|
};
|
||||||
var token = tokenHandler.CreateToken(tokenDescriptor);
|
var token = tokenHandler.CreateToken(tokenDescriptor);
|
||||||
|
|
||||||
|
var instance = _instanceService.GetById(user.InstanceId);
|
||||||
|
|
||||||
return new TokenDTO()
|
return new TokenDTO()
|
||||||
{
|
{
|
||||||
access_token = tokenHandler.WriteToken(token),
|
access_token = tokenHandler.WriteToken(token),
|
||||||
@ -80,7 +85,8 @@ namespace ManagerService.Service.Services
|
|||||||
expiration = new DateTimeOffset(token.ValidTo),
|
expiration = new DateTimeOffset(token.ValidTo),
|
||||||
token_type = "Bearer",
|
token_type = "Bearer",
|
||||||
scope = Security.Scope,
|
scope = Security.Scope,
|
||||||
instanceId = user.InstanceId
|
instanceId = user.InstanceId,
|
||||||
|
pinCode = instance.PinCode
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
catch (UnauthorizedAccessException ex)
|
catch (UnauthorizedAccessException ex)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user