External Backend

You can validate the JWT token to determine whether the user has been authenticated if you are using an external backend.

import { verify } from 'jsonwebtoken'

const validateJWT = () => {
    const authorization = req.headers["authorization"]
    
    if (!authorization) throw new Error("not authenticated")
    const token = authorization.split(" ")[1]
    
    verify(token, process.env.JWT_SECRET);
}

To validate the token, you must use the same JWT Secret.

You can use connect API to get additional data from w3auth

Last updated