Customize JWT payload

By default phpmaker JWT retrns

{
“success”: true,
“token”: “eyJ0eXAiOiJKV1QiLCJh…”
}

and when decoded i get values

{
“id”: 5,
“username”: “admin”,
“email”: “admin@example.com”,
“role”: “admin”,
“exp”: 1699999999
}

How do i add custom data from user table like CurrentUserInfo(“first_name”) , CurrentUserInfo(“phone”) etc

There is no feature to modify the payload, but if you API action uses JwtMiddleware, it will login you in so you can get all user info. If you don’t use JwtMiddleware, you can load the user yourself and get all info, e.g.

$user = LoadUserByIdentifier($decodedJwt['username']);

Thank you . which server event will i use $user = LoadUserByIdentifier($decodedJwt[‘username’]); ? and how can i use JwtMiddleware with this API action $app->get(‘/getcustomerid/{name}’, function ($request, $response, $args) {

    $name = $args\["name"\] ?? null; // Get the input value

    if ($name !== null){

        $response = $response->withJson(ExecuteRows(" SELECT \* FROM pos_product WHERE category_id='" . AdjustSql($name) . "'")); // Select the record by name and return as JSON

    }

    return $response; // Return Psr\\Http\\Message\\ResponseInterface object

});   for instance