@@ -31,6 +31,31 @@ public abstract class BaseAuthController(
3131 /// </summary>
3232 public IPAddress RequestIP => IPAddress . Parse ( Request . GetRemoteAddress ( ) ) ;
3333
34+ /// <summary>
35+ /// Logs out the current user by revoking the refresh token and removing the authentication cookie.
36+ /// </summary>
37+ /// <remarks>This endpoint supports GET, POST, and DELETE HTTP methods. If a refresh token cookie
38+ /// is present, it is revoked and deleted. If no refresh token is found, the operation completes without
39+ /// error.</remarks>
40+ /// <returns>An <see cref="IActionResult"/> indicating the result of the logout operation. Returns a success message if
41+ /// the user was logged out.</returns>
42+ [ HttpGet ( "logout" ) ]
43+ [ HttpPost ( "logout" ) ]
44+ [ HttpDelete ( "logout" ) ]
45+ public async Task < IActionResult > Logout ( [ FromQuery ] string ? token = "" )
46+ {
47+ if ( Request . Cookies . TryGetValue ( CookieRefreshTokenName , out string ? refreshToken ) )
48+ {
49+ await RevokeRefreshTokenAsync ( refreshToken ) ;
50+ Response . Cookies . Delete ( CookieRefreshTokenName ) ;
51+ }
52+ if ( ! string . IsNullOrWhiteSpace ( token ) )
53+ {
54+ await RevokeRefreshTokenAsync ( token ) ;
55+ }
56+ return Ok ( "Logged out successfully" ) ;
57+ }
58+
3459 /// <summary>
3560 /// Changes the password for the currently authenticated user.
3661 /// </summary>
@@ -248,6 +273,15 @@ public async Task<IActionResult> LoginWithGoogle([FromQuery] string token)
248273 /// <returns>A task that represents the asynchronous operation.</returns>
249274 public abstract Task SaveAndRevokeRefreshTokenAsync ( Guid userId , string oldRefreshToken , string newRefreshToken , AuthType authType ) ;
250275
276+ /// <summary>
277+ /// Revokes the specified refresh token, invalidating it for future use.
278+ /// </summary>
279+ /// <remarks>After revocation, the specified refresh token can no longer be used to obtain new
280+ /// access tokens. This method is typically used to log out a user or to respond to a security event.</remarks>
281+ /// <param name="refreshToken">The refresh token to revoke. Cannot be null or empty.</param>
282+ /// <returns>A task that represents the asynchronous revoke operation.</returns>
283+ public abstract Task RevokeRefreshTokenAsync ( string refreshToken ) ;
284+
251285 /// <summary>
252286 /// Asynchronously retrieves the unique identifier of a user associated with the specified refresh token.
253287 /// </summary>
0 commit comments