Skip to content

Commit 6cd683b

Browse files
author
Vadim Belov
committed
Make RefreshToken nullable; remove unused auth models
Changed RefreshToken in TokenPairDto to nullable string. Removed obsolete model files: LoginResponse, RefreshTokenRequest, and UsernameLoginRequest. These models are no longer used.
1 parent 03ea54c commit 6cd683b

5 files changed

Lines changed: 7 additions & 56 deletions

File tree

Sources/EasyExtensions.AspNetCore.Authorization/Controllers/BaseAuthController.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ public async Task<IActionResult> RefreshToken([FromBody] RefreshTokenRequestDto?
108108
SameSite = Microsoft.AspNetCore.Http.SameSiteMode.Strict,
109109
Expires = DateTimeOffset.UtcNow.Add(GetCookieExpirationTime()),
110110
});
111-
return Ok(new TokenPairDto
111+
return Ok(new TokenPairResponseDto
112112
{
113113
AccessToken = accessToken,
114114
RefreshToken = useCookie ? StringHelpers.CreateRandomString(64) : newRefreshToken
@@ -123,7 +123,7 @@ public async Task<IActionResult> RefreshToken([FromBody] RefreshTokenRequestDto?
123123
/// re-entering credentials. Repeated failed login attempts may be subject to rate limiting or account lockout
124124
/// policies, depending on system configuration.</remarks>
125125
/// <param name="request">The login request containing the user's username and password. Cannot be null.</param>
126-
/// <returns>An <see cref="IActionResult"/> containing a <see cref="TokenPairDto"/> with access and refresh tokens if
126+
/// <returns>An <see cref="IActionResult"/> containing a <see cref="TokenPairResponseDto"/> with access and refresh tokens if
127127
/// authentication is successful; otherwise, an unauthorized response if the credentials are invalid.</returns>
128128
[HttpPost("login")]
129129
public async Task<IActionResult> Login([FromBody] LoginRequestDto request)
@@ -164,7 +164,7 @@ public async Task<IActionResult> Login([FromBody] LoginRequestDto request)
164164
SameSite = Microsoft.AspNetCore.Http.SameSiteMode.Strict,
165165
Expires = DateTimeOffset.UtcNow.Add(GetCookieExpirationTime()),
166166
});
167-
return Ok(new TokenPairDto
167+
return Ok(new TokenPairResponseDto
168168
{
169169
AccessToken = accessToken,
170170
RefreshToken = refreshToken
@@ -180,7 +180,7 @@ public async Task<IActionResult> Login([FromBody] LoginRequestDto request)
180180
/// The method issues new tokens and revokes any previous refresh tokens for the user.</remarks>
181181
/// <param name="token">The Google OAuth access token to use for retrieving user information. Must be a valid token issued by
182182
/// Google.</param>
183-
/// <returns>An <see cref="IActionResult"/> containing a <see cref="TokenPairDto"/> with access and refresh tokens if
183+
/// <returns>An <see cref="IActionResult"/> containing a <see cref="TokenPairResponseDto"/> with access and refresh tokens if
184184
/// authentication is successful; otherwise, an unauthorized response if authentication fails or the user's
185185
/// email is not verified.</returns>
186186
/// <exception cref="InvalidOperationException">Thrown if user information cannot be retrieved from Google using the provided token.</exception>
@@ -220,7 +220,7 @@ public async Task<IActionResult> LoginWithGoogle([FromQuery] string token)
220220
SameSite = Microsoft.AspNetCore.Http.SameSiteMode.Strict,
221221
Expires = DateTimeOffset.UtcNow.Add(GetCookieExpirationTime()),
222222
});
223-
return Ok(new TokenPairDto
223+
return Ok(new TokenPairResponseDto
224224
{
225225
AccessToken = accessToken,
226226
RefreshToken = refreshToken

Sources/EasyExtensions.AspNetCore.Authorization/Models/Dto/TokenPairDto.cs renamed to Sources/EasyExtensions.AspNetCore.Authorization/Models/Dto/TokenPairResponseDto.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
/// <remarks>A token pair typically consists of an access token, which is used to authorize API requests,
77
/// and a refresh token, which can be used to obtain a new access token when the current one expires. This class is
88
/// commonly used in authentication flows that require token management.</remarks>
9-
public class TokenPairDto
9+
public class TokenPairResponseDto
1010
{
1111
/// <summary>
1212
/// Gets or sets the OAuth 2.0 access token used for authenticating API requests.
@@ -16,6 +16,6 @@ public class TokenPairDto
1616
/// <summary>
1717
/// Gets or sets the refresh token used to obtain a new access token when the current one expires.
1818
/// </summary>
19-
public string RefreshToken { get; set; } = null!;
19+
public string? RefreshToken { get; set; } = null!;
2020
}
2121
}

Sources/EasyExtensions/Models/LoginResponse.cs

Lines changed: 0 additions & 18 deletions
This file was deleted.

Sources/EasyExtensions/Models/RefreshTokenRequest.cs

Lines changed: 0 additions & 13 deletions
This file was deleted.

Sources/EasyExtensions/Models/UsernameLoginRequest.cs

Lines changed: 0 additions & 18 deletions
This file was deleted.

0 commit comments

Comments
 (0)