Token Verification
You can verify the validity of an encrypted token and retrieve the username by calling the extractUserWithVerify()
method.
How to Verify the Encrypted Token
src/index.ts
.("/verify", async () => {
const = ..("token");
const = await .();
if (.) {
return .();
} else {
return .();
}
});
If the token is valid, a response like the following will be returned:
Response
{
"success": true,
"data": "***********"
}
Internal Behavior of Verification
extractUserWithVerify()
checks the following conditions:
- Whether a token is provided
- Whether the token has been tampered with
Authentication is only considered successful if all conditions are met.
Error Examples and Solutions
Error Message | Cause | Solution |
---|---|---|
Token not provided | Token argument is missing | Add the token argument |
Invalid token format | Format is incorrect | Ensure the token hasn’t been altered |
Last updated on