Bläddra i källkod

Bugfixed build

Feature
Safet Purkovic 4 år sedan
förälder
incheckning
a0728dcba5

+ 6
- 7
BlackRock.Reporting.API/Authentication/JwtManager.cs Visa fil

@@ -9,17 +9,16 @@ namespace BlackRock.Reporting.API.Authentication
public class JwtManager : IJwtManager
{
//private string Secret = "db3OIsj+BXE9NZDy0t8W3TcNekrF+2d/1sFnWG4HnV8TZY30iTOdtVWJG8abWvB1GlOgJuQZdcF2Luqm/hccMw==";
//private readonly IConfiguration configuration;
private readonly IConfiguration configuration;

private readonly string Secret;
//public JwtManager(IConfiguration configuration)
//{
// this.configuration = configuration;
// Secret = configuration["SecurityKey"];
//}
public JwtManager(IConfiguration configuration)
{
this.configuration = configuration;
Secret = configuration["SecurityKey"];
}
public string GenerateToken(string username, int expireMinutes = 20)
{
expireMinutes = 1;
var symmetricKey = Convert.FromBase64String(Secret);
var tokenHandler = new JwtSecurityTokenHandler();
var now = DateTime.UtcNow;

+ 0
- 1
BlackRock.Reporting.API/Controllers/AuthenticationController.cs Visa fil

@@ -1,5 +1,4 @@
using BlackRock.Reporting.API.Mediator.AuthenticationMediator.Commands;
using BlackRock.Reporting.API.Mediator.AuthenticationMediator.Models;
using MediatR;
using Microsoft.AspNetCore.Mvc;


+ 5
- 5
BlackRock.Reporting.API/Mediator/AuthenticationMediator/Commands/LoginCommand.cs Visa fil

@@ -16,11 +16,11 @@ namespace BlackRock.Reporting.API.Mediator.AuthenticationMediator.Commands
public class LoginCommandHandlers : IRequestHandler<LoginCommand, Result<CredentialsCommand>>
{
private readonly ILogger<LoginCommand> logger;
private readonly JwtManager jwtManager;
private readonly RefreshTokenManager refreshTokenManager;
private readonly IJwtManager jwtManager;
private readonly IRefreshTokenManager refreshTokenManager;
private readonly UserManager<ApplicationUser> userManager;

public LoginCommandHandlers(ILogger<LoginCommand> logger, JwtManager jwtManager, RefreshTokenManager refreshTokenManager, UserManager<ApplicationUser> userManager)
public LoginCommandHandlers(ILogger<LoginCommand> logger, IJwtManager jwtManager, IRefreshTokenManager refreshTokenManager, UserManager<ApplicationUser> userManager)
{
this.logger = logger;
this.jwtManager = jwtManager;
@@ -57,8 +57,8 @@ namespace BlackRock.Reporting.API.Mediator.AuthenticationMediator.Commands
}
catch (Exception ex)
{
logger.LogError(ex, "Faild to add data to DB.");
return new Result<CredentialsCommand> { IsSuccess = false, Error = "Faild to add data to DB." };
logger.LogError(ex, "Faild login");
return new Result<CredentialsCommand> { IsSuccess = false, Error = "Faild login." };
}
}
}

+ 3
- 3
BlackRock.Reporting.API/Mediator/AuthenticationMediator/Commands/LogoutCommand.cs Visa fil

@@ -14,11 +14,11 @@ namespace BlackRock.Reporting.API.Mediator.AuthenticationMediator.Commands
public class LogoutCommandHandlers : IRequestHandler<LogoutCommand, Result<bool>>
{
private readonly ILogger<LogoutCommand> logger;
private readonly JwtManager jwtManager;
private readonly RefreshTokenManager refreshTokenManager;
private readonly IJwtManager jwtManager;
private readonly IRefreshTokenManager refreshTokenManager;
private readonly UserManager<ApplicationUser> userManager;

public LogoutCommandHandlers(ILogger<LogoutCommand> logger, JwtManager jwtManager, RefreshTokenManager refreshTokenManager, UserManager<ApplicationUser> userManager)
public LogoutCommandHandlers(ILogger<LogoutCommand> logger, IJwtManager jwtManager, IRefreshTokenManager refreshTokenManager, UserManager<ApplicationUser> userManager)
{
this.logger = logger;
this.jwtManager = jwtManager;

+ 3
- 3
BlackRock.Reporting.API/Mediator/AuthenticationMediator/Commands/RefreshCommand.cs Visa fil

@@ -14,11 +14,11 @@ namespace BlackRock.Reporting.API.Mediator.AuthenticationMediator.Commands
public class RefreshCommandHandlers : IRequestHandler<RefreshCommand, Result<CredentialsCommand>>
{
private readonly ILogger<RefreshCommand> logger;
private readonly JwtManager jwtManager;
private readonly RefreshTokenManager refreshTokenManager;
private readonly IJwtManager jwtManager;
private readonly IRefreshTokenManager refreshTokenManager;
private readonly UserManager<ApplicationUser> userManager;

public RefreshCommandHandlers(ILogger<RefreshCommand> logger, JwtManager jwtManager, RefreshTokenManager refreshTokenManager, UserManager<ApplicationUser> userManager)
public RefreshCommandHandlers(ILogger<RefreshCommand> logger, IJwtManager jwtManager, IRefreshTokenManager refreshTokenManager, UserManager<ApplicationUser> userManager)
{
this.logger = logger;
this.jwtManager = jwtManager;

Laddar…
Avbryt
Spara