File tree Expand file tree Collapse file tree 3 files changed +23
-3
lines changed Expand file tree Collapse file tree 3 files changed +23
-3
lines changed Original file line number Diff line number Diff line change @@ -172,17 +172,17 @@ public async Task<IActionResult> RefreshToken([FromBody] RefreshTokenRequestDto
172172 if ( string . IsNullOrEmpty ( request . Token ) )
173173 return BadRequest ( new { message = "Token is required" } ) ;
174174
175- // Extract token ID (jti claim)
175+ // Extract the token ID (jti claim)
176176 var tokenId = _tokenService . ExtractTokenId ( request . Token ) ;
177177
178178 if ( string . IsNullOrEmpty ( tokenId ) )
179179 return BadRequest ( new { message = "Invalid token" } ) ;
180180
181- // Check if token is blacklisted
181+ // Check if the token is blacklisted
182182 if ( await _tokenBlacklistRepository . IsTokenBlacklistedAsync ( tokenId ) )
183183 return Unauthorized ( new { message = "Token has been revoked" } ) ;
184184
185- var principal = _tokenService . ValidateToken ( request . Token ) ;
185+ var principal = _tokenService . ValidateTokenForRefresh ( request . Token ) ;
186186
187187 if ( principal == null )
188188 return Unauthorized ( new { message = "Invalid token" } ) ;
Original file line number Diff line number Diff line change @@ -10,4 +10,5 @@ public interface ITokenService
1010 ClaimsPrincipal ValidateToken ( string token ) ;
1111 DateTime GetTokenExpirationTime ( string token ) ;
1212 string ExtractTokenId ( string token ) ;
13+ ClaimsPrincipal ValidateTokenForRefresh ( string token ) ;
1314}
Original file line number Diff line number Diff line change @@ -124,4 +124,23 @@ public string ExtractTokenId(string token)
124124
125125 return null ;
126126 }
127+
128+ public ClaimsPrincipal ValidateTokenForRefresh ( string token )
129+ {
130+ var tokenHandler = new JwtSecurityTokenHandler ( ) ;
131+ var key = Encoding . UTF8 . GetBytes ( _jwtSettings . SecretKey ) ;
132+
133+ var validationParameters = new TokenValidationParameters
134+ {
135+ ValidateIssuer = true ,
136+ ValidateAudience = true ,
137+ ValidateLifetime = false , // This is the key change - don't validate lifetime for refresh
138+ ValidateIssuerSigningKey = true ,
139+ ValidIssuer = _jwtSettings . Issuer ,
140+ ValidAudience = _jwtSettings . Audience ,
141+ IssuerSigningKey = new SymmetricSecurityKey ( key ) ,
142+ } ;
143+
144+ return tokenHandler . ValidateToken ( token , validationParameters , out _ ) ;
145+ }
127146}
You can’t perform that action at this time.
0 commit comments