curl --request GET \
--url https://api.example.com/api/auth/get-me{
"message": "Token not provided."
}
Retrieve the currently authenticated user details
curl --request GET \
--url https://api.example.com/api/auth/get-me{
"message": "Token not provided."
}
authUser middleware validates the JWT token before processing the request.token cookie. The token is automatically included when using the same session that performed login or registration.
authUser middleware performs the following checks:
token cookie is presentJWT_SECRETreq.usertoken cookie.
{
"message": "User details fetched successfully",
"user": {
"id": "507f1f77bcf86cd799439011",
"username": "johndoe",
"email": "[email protected]"
}
}
{
"message": "Token not provided."
}
curl -X GET https://api.example.com/api/auth/get-me \
-b cookies.txt
authUser middlewaretoken cookiereq.user.id)Check Authentication Status
Display User Profile
Token Validation