diff --git a/Tsi1.Api/Tsi1.Api/Controllers/UserController.cs b/Tsi1.Api/Tsi1.Api/Controllers/UserController.cs index 772ed5dc946636f7ff870da69791b068c2483633..e0ffd0bdcf77ca13a2325f737c369a4cc7785740 100644 --- a/Tsi1.Api/Tsi1.Api/Controllers/UserController.cs +++ b/Tsi1.Api/Tsi1.Api/Controllers/UserController.cs @@ -482,5 +482,12 @@ namespace Tsi1.Api.Controllers return Ok(); } + + [AllowAnonymous] + [HttpGet("GetAllRefreshTokens")] + public async Task<IActionResult> GetAllRefreshTokens() + { + return Ok(_jwtAuthManager.GetRefreshTokens()); + } } } diff --git a/Tsi1.Api/Tsi1.Api/Infrastructure/IJwtAuthManager.cs b/Tsi1.Api/Tsi1.Api/Infrastructure/IJwtAuthManager.cs index ab8bf680e9aa66084d608abaa9cc6b9a57c182ee..15caef0244faf3bea3583c87cae572f728d3aaa6 100644 --- a/Tsi1.Api/Tsi1.Api/Infrastructure/IJwtAuthManager.cs +++ b/Tsi1.Api/Tsi1.Api/Infrastructure/IJwtAuthManager.cs @@ -1,4 +1,5 @@ using System; +using System.Collections.Generic; using System.Collections.Immutable; using System.IdentityModel.Tokens.Jwt; using System.Security.Claims; @@ -17,5 +18,6 @@ namespace Tsi1.Api.Infrastructure int GenerateVerificationCode(string username, DateTime now); bool ValidateVerificationCode(string username, int code); public void RemoveExpiredVerificationCodes(DateTime now); + public IEnumerable<RefreshToken> GetRefreshTokens(); } } diff --git a/Tsi1.Api/Tsi1.Api/Infrastructure/JwtAuthManager.cs b/Tsi1.Api/Tsi1.Api/Infrastructure/JwtAuthManager.cs index f1bf057d038a817c83884e80eb99bece1e185bf2..bad78f3a887bb494058a7f8f94d0e3d85f3c9764 100644 --- a/Tsi1.Api/Tsi1.Api/Infrastructure/JwtAuthManager.cs +++ b/Tsi1.Api/Tsi1.Api/Infrastructure/JwtAuthManager.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Concurrent; +using System.Collections.Generic; using System.Collections.Immutable; using System.IdentityModel.Tokens.Jwt; using System.Linq; @@ -150,6 +151,11 @@ namespace Tsi1.Api.Infrastructure } } + public IEnumerable<RefreshToken> GetRefreshTokens() + { + return _usersRefreshTokens.Select(x => x.Value).ToList(); + } + private static string GenerateRefreshTokenString() { var randomNumber = new byte[32];