pub async fn refresh_token(
__arg0: State<DB>,
__arg1: Json<RefreshTokenRequest>,
) -> (StatusCode, Json<AuthTokenResponse>)Expand description
Handles token refresh requests This endpoint allows clients to obtain a new access token using a valid refresh token. It verifies the refresh token, checks its validity in the database, and generates a new access token if everything is valid. The refresh token is not rotated in this implementation, but it can be easily modified to do so if desired.
§Arguments
State(_db)- Shared state containing the database connection (not used but required by Axum)Json(payload)- The refresh token request payload containing the refresh token
§Returns
(StatusCode, Json<AuthTokenResponse>)- The HTTP status code and JSON response containing the new access token or an error message
§Error
StatusCode::UNAUTHORIZED- If the refresh token is invalid, expired, of the wrong type, or not found in the databaseStatusCode::INTERNAL_SERVER_ERROR- If there is an error generating the new access token
§Example
let payload = RefreshTokenRequest {
refresh_token: "valid_refresh_token".to_string(),
};